Jump to content

Recommended Posts

I am working with a PIC18F18722 and am looking to write a custom boot loader. I create a simple application to flash some LEDs:


16: void main(void)

17: {

18: unsigned char leds = 0;

00004 6A01 CLRF 0x1, ACCESS

19: unsigned short delay1;

20: unsigned short counter = 0;

00006 6A04 CLRF 0x4, ACCESS

00008 6A05 CLRF 0x5, ACCESS


22: // access to the LEDS

23: trisd = 0;

0000A 6A95 CLRF 0xf95, ACCESS


25: while (1)

26: {

27: portd = leds++;

0000C 5001 MOVF 0x1, W, ACCESS

0000E 6E83 MOVWF 0xf83, ACCESS

00010 2A01 INCF 0x1, F, ACCESS

28: for(delay1 = 0; delay1 < 64000; delay1++)

00012 6A02 CLRF 0x2, ACCESS

00014 6A03 CLRF 0x3, ACCESS

00016 0EFA MOVLW 0xfa

00018 5C03 SUBWF 0x3, W, ACCESS

0001A E102 BNZ 0x20

0001C 0E00 MOVLW 0

0001E 5C02 SUBWF 0x2, W, ACCESS

00020 E2F5 BC 0xc

00026 4A02 INFSNZ 0x2, F, ACCESS

00028 2A03 INCF 0x3, F, ACCESS

0002A D7F5 BRA 0x16

29: counter++;

00022 4A04 INFSNZ 0x4, F, ACCESS

00024 2A05 INCF 0x5, F, ACCESS


This produces the following HEX file:










According to the documentation I have the the first line of the HEX file here defines the start address upper segment as zero. The following 3 lines are code that is offset at 0, 16 and 32 respectively. Not being familiar with the assembler and machine code I determined that the first bit of code is a GOTO instruction to address 16Hex. The following data matches the disassembly in the code. My question concerns the interrupt vectors which are located after the reset vector - won't they be overwritten in this instance? I would have expected the code for the reset vector on it's own with the application code located after the 'reserved area'. Am I missing something?

Link to post
Share on other sites

If you have no interrupt vectors defined in your code then the code space for them is free for the linker to put whatever it wants in that space.


Put interrupt() and/or interrupt_low() into your code and things will change.





Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...