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

#org default

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







#org default
PostPosted: Fri May 16, 2003 5:02 am     Reply with quote

hi,

my application (18F252) use a "loader" for remote (gsm) program upload..
the program code are trasmitted and stored in a external EEPROM,
and then the program call my loader() function what copy from
external eeprom to internal flash (with exclusion, off course, of
loader code) and restart the processor..

This is my loader function:

#org 0x7d80,0x7fff AUTO=0 DEFAULT
void loader(void)
{
#use i2c(master,fast,sda=pin_c4, scl=pin_c3, restart_wdt)
int16 indirizzo;
int8 n;
restart_wdt();
disable_interrupts(global);
disable_interrupts(int_rda);
disable_interrupts(int_rtcc);
disable_interrupts(int_timer1);
disable_interrupts(int_ext);
disable_interrupts(global);
restart_wdt();
i2c_start();
i2c_write(0b10101110);
i2c_write(0x00);
i2c_write(0x40);
i2c_start();
i2c_write(0b10101111);
for (indirizzo=0x0200;indirizzo<0x7d80;indirizzo=indirizzo+64)
{
for(n=0;n<64;n++){restart_wdt();g_stg[n]=i2c_read();}
WRITE_PROGRAM_MEMORY((int32)indirizzo, g_stg, 64);
}
n = i2c_read(0);
i2c_stop();
reset_cpu();
}
#org default

The program run very good...
What is the problem ???
the "entry point" of the loader is not 0x7d80 (the start of the reserved space), but
another:

.................... loader();
2C7A: CALL 7E4C

due to the fact that this function STAY UNCHANGED FOREVER, if a future change in
compiler philosophy will move this "entry point", the future call to loader()
will point to another location, and the new program version will crash when
will point to the loader() function...

Then, is possible to FORCE a fixed entry point address of a function,
avoiding any problem in future compilation ???

thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514503
Andy Drummond
Guest







Re: #org default
PostPosted: Fri May 16, 2003 10:00 am     Reply with quote

Hello. I have done something almost identical. i think that the compiler is inserting the i2c code before your loader routine. What I did was to leave a small amount at the end for the i2c by using:
#org 0x7800, 0x7E80 DEFAULT
Then the I2C when in at the end. But at the very start of the program I put
#org 0x100,0x77FF
which "used up" all the program space thus preventing the compiler from putting the i2c code anywhere else.
Good luck,
Andy Drummond

:=hi,
:=
:=my application (18F252) use a "loader" for remote (gsm) program upload..
:=the program code are trasmitted and stored in a external EEPROM,
:=and then the program call my loader() function what copy from
:=external eeprom to internal flash (with exclusion, off course, of
:=loader code) and restart the processor..
:=
:=This is my loader function:
:=
:=#org 0x7d80,0x7fff AUTO=0 DEFAULT
:=void loader(void)
:={
:= #use i2c(master,fast,sda=pin_c4, scl=pin_c3, restart_wdt)
:= int16 indirizzo;
:= int8 n;
:= restart_wdt();
:= disable_interrupts(global);
:= disable_interrupts(int_rda);
:= disable_interrupts(int_rtcc);
:= disable_interrupts(int_timer1);
:= disable_interrupts(int_ext);
:= disable_interrupts(global);
:= restart_wdt();
:= i2c_start();
:= i2c_write(0b10101110);
:= i2c_write(0x00);
:= i2c_write(0x40);
:= i2c_start();
:= i2c_write(0b10101111);
:= for (indirizzo=0x0200;indirizzo<0x7d80;indirizzo=indirizzo+64)
:= {
:= for(n=0;n<64;n++){restart_wdt();g_stg[n]=i2c_read();}
:= WRITE_PROGRAM_MEMORY((int32)indirizzo, g_stg, 64);
:= }
:= n = i2c_read(0);
:= i2c_stop();
:= reset_cpu();
:=}
:=#org default
:=
:=The program run very good...
:=What is the problem ???
:=the "entry point" of the loader is not 0x7d80 (the start of the reserved space), but
:=another:
:=
:=.................... loader();
:=2C7A: CALL 7E4C
:=
:=due to the fact that this function STAY UNCHANGED FOREVER, if a future change in
:=compiler philosophy will move this "entry point", the future call to loader()
:=will point to another location, and the new program version will crash when
:=will point to the loader() function...
:=
:=Then, is possible to FORCE a fixed entry point address of a function,
:=avoiding any problem in future compilation ???
:=
:=thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 144514510
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