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

PIC18F452 Bootloader-How to PLACE "#USE RS232" in

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



Joined: 26 Mar 2005
Posts: 10

View user's profile Send private message Send e-mail ICQ Number

PIC18F452 Bootloader-How to PLACE "#USE RS232" in
PostPosted: Sat Mar 26, 2005 3:13 am     Reply with quote

Hi everybody Very Happy
So, this is my HUGE problem:
I've imlemented bootloader into my PIC. It's working fine until reaching the 10 lines generated by "#use RS232...". As these 10 lines are placed exactly at the beginnig of the main() function and the bootloader use them for recieving/sending data, when they are erased by write_program_memory function, the loader stops there!
My question is how can I place "#use RS232" whereever I want?
I've tryed with #ORG or placing it into bootloader section, but no results...

Thanks.


Last edited by Predator_MF on Sat Mar 26, 2005 5:58 am; edited 1 time in total
Ttelmah
Guest







PostPosted: Sat Mar 26, 2005 3:48 am     Reply with quote

To move the core parts of the program, use #build. A search for this term on the forum, will show you how to use this with a bootloader. #org, allows you to put blocks of code at specific locations 'inside' the area being used, but the compiler still requires it's own code to go at the bottom of memory. #build allows you to change this.

Best Wishes
Predator_MF



Joined: 26 Mar 2005
Posts: 10

View user's profile Send private message Send e-mail ICQ Number

PostPosted: Sat Mar 26, 2005 4:00 am     Reply with quote

As I understand #build shows the compilator where RESET and INTERRUPT vectors are placed. How exactly this would help me?

Code:
#use rs232(baud=500000,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,enable=PIN_D0)
*
0E6E:  BCF    F95.0
0E70:  BSF    F8C.0
0E72:  BTFSS  F9E.4
0E74:  BRA    0E72
0E76:  MOVLB  5
0E78:  MOVFF  51C,FAD
0E7C:  NOP
0E7E:  BCF    F95.0
0E80:  BSF    F8C.0
0E82:  BTFSS  FAC.1
0E84:  BRA    0E82
0E86:  BCF    F95.0
0E88:  BCF    F8C.0
0E8A:  MOVLB  0
0E8C:  RETLW  00
0E8E:  NOP(FFFF)


I want this code to be placed in the bootloader area!
Ttelmah
Guest







PostPosted: Sat Mar 26, 2005 4:23 am     Reply with quote

You should be building two seperate programs. The first is your bootloader, and presumably needs to have it's entry vector at the bottom of memory as 'normal'. The second is the program to load with your bootloader, which needs to avoid the bottom of memory area. This is then built using #build, to avoid it overwriting the bootloader, and the jump vectors placed by the bootloader. A program 'built' with the build option, with it's entry point moved up, places the standard routines like the timing code for RS232, similarly relocated upwards as well.

Best Wishes
Predator_MF



Joined: 26 Mar 2005
Posts: 10

View user's profile Send private message Send e-mail ICQ Number

PostPosted: Sat Mar 26, 2005 5:51 am     Reply with quote

How hard this could be!!! However I try, the #USE RS232 code is always placed at some location that compilator have chosen. I've tryed a stand-alone code with #build (RESET = 0x7AFF) and the #USE RS232 is placed at 01C40...WHY?
Guest








PostPosted: Sat Mar 26, 2005 6:52 am     Reply with quote

if you use the #org with DEFAULT option and a #use rs232 inside the area defined by #org, ALL code are placed inside this area. you can place another #use rs232 in the main program. i use this for my LOADER, not BOOTLOADER (a loader function what update the program under main program control.. ) . in my case i receive the new program code from a GSM modem, store it into an external eeprom, and then i copy this into the CPU, MANTAINING the control of the operation ...
If is this what you want, here is the code what i use:


#org 0x7d0a,0x7fff AUTO=0 DEFAULT
void loader1(void)
{
/*
il codice e' scritto in eeprom a partire dal "blocco" E000 a blocco FFFF (ultimi 32K della eeprom ext)
viene copiato su eeprom_pic (esclusa la zona tra 0x00 0x1ff (bootloader) e la zona 0x7d00 0x7fff (loader).

NON AGGIUNGERE NULLA CHE FACCIA RIFERIMENTO A PEZZI DI CODICE FUORI DA QUESTO INTERVALLO

*/

// nel programma ci sono piu' #use i2c .. questo e' usato SOLO dal loader ..
#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); // scrive l'indirizzo
i2c_write(0x02); // parte superiore dell'indirizzo vero di inizio blocco dati (primo byte di banco 1 eeprom 03)
i2c_write(0x00); // parte inferiore
i2c_start();
i2c_write(0b10101111); // adesso legge
for (indirizzo=0x0200;indirizzo<0x7d00;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); // fittizzio, solo per NON dare ack alla eeprom ( -> ..(0) ) prima dello STOP
i2c_stop();
reset_cpu();
}
#org default


enjoy .
Mauro ik1wvq
Ttelmah
Guest







PostPosted: Sat Mar 26, 2005 6:56 am     Reply with quote

Look at bootload.c, and bootloader.c, together with the include files. Basically you cannot reserve the base area, unless you have moved the vectors (obvious really), but you still have to do the reservation seperately. Also it is vital that the reservations are made before the clock definition line, and the RS232 definiton line (if you are using software RS232), otherwise both will still stick code into the unreserved areas.

Best Wishes
Predator_MF



Joined: 26 Mar 2005
Posts: 10

View user's profile Send private message Send e-mail ICQ Number

PostPosted: Sat Mar 26, 2005 7:01 am     Reply with quote

Mauro wrote:
a loader function what update the program under main program control..


This is exactly what I'm trying to do! Thanks alot...
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Mon Mar 28, 2005 9:02 am     Reply with quote

Predator_MF wrote:
Mauro wrote:
a loader function what update the program under main program control..


This is exactly what I'm trying to do! Thanks alot...

next, you will need to read this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=20282

jds-pic
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