CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Bootloader: #device statements not amenable to #org position

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kw



Joined: 26 Apr 2010
Posts: 2

View user's profile Send private message

Bootloader: #device statements not amenable to #org position
PostPosted: Mon Apr 26, 2010 7:29 am     Reply with quote

I am trying to create a bootloader and I cannot use something off the shelf due to the way information is received.

I need to obtain precise code positioning.

I managed to use 'default' as an option to the #org directives to map out pieces of code created by "#use" (such as "#use delay").

However, a #device directive generates code that cannot be positioned (#org statements before #device generate an error).

The problem is that without precise positioning of #device generated code, this code is liable to being overwritten by the bootloader - evidently this "#device" code includes general use stuff because my bootloader code jumps to it. When it's overwritten - kaboom.

Is there a way to tell the compiler to put #device generated code at a particular location?
kw



Joined: 26 Apr 2010
Posts: 2

View user's profile Send private message

Re: Bootloader: #device statements not amenable to #org posi
PostPosted: Mon Apr 26, 2010 8:18 am     Reply with quote

By the way I am exploring further and see that erase_program_eprom calls a subroutine inside the generated code for #device.

Code:
....................                erase_program_eeprom(rompos);
0F2C:  MOVF   55,W
0F2D:  BSF    03.6
0F2E:  MOVWF  0D
0F2F:  BCF    03.6
0F30:  MOVF   56,W
0F31:  BSF    03.6
0F32:  MOVWF  0F
0F33:  BSF    03.5
0F34:  BSF    0C.7
0F35:  BSF    0C.4
0F36:  BSF    0C.2
0F37:  BCF    0A.3
0F38:  BCF    03.5
0F39:  BCF    03.6
0F3A:  GOTO   12D
0F3B:  BSF    0A.3
0F3C:  BSF    03.5
0F3D:  BSF    03.6
0F3E:  BCF    0C.4
0F3F:  BCF    03.5
0F40:  BCF    03.6


Check that 12d... here's what #device spits out.

Code:
.................... #device PIC16F88
*
012D:  MOVF   0B,W
012E:  MOVWF  78
012F:  BCF    0B.7
0130:  BSF    03.5
0131:  BSF    03.6
0132:  MOVLW  55
0133:  MOVWF  0D
0134:  MOVLW  AA
0135:  MOVWF  0D
0136:  BSF    0C.1
0137:  GOTO   138
0138:  BTFSC  0C.1
0139:  GOTO   138
013A:  BCF    0C.2
013B:  MOVF   78,W
013C:  BCF    03.5
013D:  BCF    03.6
013E:  IORWF  0B,F
013F:  BSF    0A.3
0140:  GOTO   73B (RETURN)
0141:  MOVF   0B,W
0142:  MOVWF  04
0143:  BCF    0B.7
0144:  MOVLW  FC
0145:  BSF    03.6
0146:  ANDWF  0D,F
0147:  BSF    03.5
0148:  BSF    0C.7
0149:  BSF    0C.2
014A:  MOVLW  04
014B:  MOVWF  77
014C:  BCF    03.5
014D:  MOVF   0D,W
014E:  SUBWF  7A,W
014F:  BTFSC  03.2
0150:  GOTO   156
0151:  BSF    03.5
0152:  BSF    0C.0
0153:  GOTO   154
0154:  GOTO   15B
0155:  BCF    03.5
0156:  MOVF   78,W
0157:  MOVWF  0C
0158:  MOVF   79,W
0159:  MOVWF  0E
015A:  BSF    03.5
015B:  MOVLW  55
015C:  MOVWF  0D
015D:  MOVLW  AA
015E:  MOVWF  0D
015F:  BSF    0C.1
0160:  GOTO   161
0161:  GOTO   162
0162:  BCF    03.5
0163:  INCF   0D,F
0164:  DECFSZ 77,F
0165:  GOTO   14D
0166:  BSF    03.5
0167:  BTFSC  0C.1
0168:  GOTO   167
0169:  BCF    0C.2
016A:  MOVF   04,W
016B:  BCF    03.5
016C:  BCF    03.6
016D:  IORWF  0B,F
016E:  BSF    0A.3
016F:  GOTO   778 (RETURN)
*
018A:  CLRF   78
018B:  CLRF   79
018C:  CLRF   77
018D:  CLRF   7A
018E:  MOVF   64,W
018F:  BTFSS  03.2
0190:  GOTO   194
0191:  MOVF   63,W
0192:  BTFSC  03.2
0193:  GOTO   1AE
0194:  MOVLW  10
0195:  MOVWF  65
0196:  BCF    03.0
0197:  RLF    61,F
0198:  RLF    62,F
0199:  RLF    77,F
019A:  RLF    7A,F
019B:  MOVF   64,W
019C:  SUBWF  7A,W
019D:  BTFSS  03.2
019E:  GOTO   1A1
019F:  MOVF   63,W
01A0:  SUBWF  77,W
01A1:  BTFSS  03.0
01A2:  GOTO   1AA
01A3:  MOVF   63,W
01A4:  SUBWF  77,F
01A5:  BTFSS  03.0
01A6:  DECF   7A,F
01A7:  MOVF   64,W
01A8:  SUBWF  7A,F
01A9:  BSF    03.0
01AA:  RLF    78,F
01AB:  RLF    79,F
01AC:  DECFSZ 65,F
01AD:  GOTO   196
01AE:  BCF    0A.3
01AF:  GOTO   1E8 (RETURN)
*
0218:  MOVLW  10
0219:  BSF    03.5
021A:  MOVWF  2C
021B:  CLRF   77
021C:  CLRF   7A
021D:  RRF    29,F
021E:  RRF    28,F
021F:  BTFSS  03.0
0220:  GOTO   227
0221:  MOVF   2A,W
0222:  ADDWF  77,F
0223:  BTFSC  03.0
0224:  INCF   7A,F
0225:  MOVF   2B,W
0226:  ADDWF  7A,F
0227:  RRF    7A,F
0228:  RRF    77,F
0229:  RRF    79,F
022A:  RRF    78,F
022B:  DECFSZ 2C,F
022C:  GOTO   21D
022D:  BCF    03.5
022E:  RETLW  00
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 26, 2010 12:29 pm     Reply with quote

Make a very short (just a few lines) test program that is compilable,
and that demonstrates the problem. For example, just call the
erase_program_eeprom() function in your code, and explain where
the CCS library code is put (ie., the address), and where you would
like it to be.

In other words, your main() will consist of just the call to that function,
and a while(1); line at the end. But the program should have the
#include for the PIC, #fuses, and #use delay(), #org statements, and
any minimal bootloader code that is required.

The more simple you make the test program, the easier it will be to
give you an answer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group