View previous topic :: View next topic |
Author |
Message |
chingB
Joined: 29 Dec 2003 Posts: 81
|
CCS BootLoader Code Help |
Posted: Sun Jan 16, 2005 6:47 am |
|
|
Hello,
I have modified the bootloader example of CCS especially the portion as listed below:
Code: |
void main(void) {
if(!input(PIN_B4))
load_program();
application();
}
|
I change the code above with
Code: |
void main(void)
{
int8 iData=0;
iData = read_eeprom(26); // get the marker
if (iData == FWU_MARKER || iData == FWU_EMPTY) // if marker=FWU_MARKER
{
output_high(PIN_B0); // Begin FW upgrade
load_program(); // load the loader prgm
if (DoneFlag) // check if completed
{
write_eeprom(26,FWU_EMPTY); // reset FW marker
#asm nop #endasm // by writing to eeprom
write_eeprom(26,FWU_ENDMKR);
#asm nop #endasm
}
}
application(); // run new firmware
}
|
While my PIC is running, I send a command thru serial com and the my PIC will write to an internal eeprom such that when it reset it will read the internal eeprom and initiate a firmware upgrade...
My concern really is... after the bootloader completed the firmware upgrade it will auto reset the MCU and load the application program or the new firmware code... after this sequence... I send a command to the PICmicro and I notice it does not responds to the command ...
so what I did, I press the hardware reset <button reset> then I send the command.. this time the MCU responded....
Now, to justify the cause I press the button or command the PIC to soft reset... after this send a command and it did respond.
To replicate the problem I send a command for a firmware upgrade... after the completion... the PIC soft reset... then I send a command... the problem occur again!!!!
Anybody has any idea of how can address this matter? Is there a need for me reset some register ?
Need your comments and suggestions...
Thanx |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jan 16, 2005 10:07 am |
|
|
Which processor are you using?
On the PIC18 series a reset command is a true hardware reset. The soft-reset command in the PIC16 series is not a true reset but only a jump to the reset address, any changed registers changed by the bootloader won't be reset to their original settings. This might be your problem.
Which version of the CCS bootloader are you using? The last year some changes and bug fixes have been applied, see the version history on the CCS website.
Code: | if (DoneFlag) // check if completed
{
write_eeprom(26,FWU_EMPTY); // reset FW marker
#asm nop #endasm // by writing to eeprom
write_eeprom(26,FWU_ENDMKR);
#asm nop #endasm
}
| Both write_eeprom calls are to the same address.... the first call is not needed. Eeprom is automatically cleared when writing; from the PIC16F87xA manual: Quote: | A byte write in data EEPROM memory automatically erases the location
and writes the new data (erase-before-write). |
|
|
|
chingB
Joined: 29 Dec 2003 Posts: 81
|
|
Posted: Sun Jan 16, 2005 5:00 pm |
|
|
ckielstra wrote: | Which processor are you using?
On the PIC18 series a reset command is a true hardware reset. The soft-reset command in the PIC16 series is not a true reset but only a jump to the reset address, any changed registers changed by the bootloader won't be reset to their original settings. This might be your problem.
Which version of the CCS bootloader are you using? The last year some changes and bug fixes have been applied, see the version history on the CCS website.
I am using the PCWH v3.188 which included a sample CCS Bootloader. I am also using the PIC18F452 PICmicro.
Code: | if (DoneFlag) // check if completed
{
write_eeprom(26,FWU_EMPTY); // reset FW marker
#asm nop #endasm // by writing to eeprom
write_eeprom(26,FWU_ENDMKR);
#asm nop #endasm
}
|
Both write_eeprom calls are to the same address.... the first call is not needed. Eeprom is automatically cleared when writing; from the PIC16F87xA manual: Quote: | A byte write in data EEPROM memory automatically erases the location
and writes the new data (erase-before-write). |
|
Thank you for the comment on the write_eeprom thing.
Even though I am using the PIC18F452, the problem is still there. What are the register necessary to be updated after bootloading the new firmware?
Do you have a copy of the CCS bootloader since it has some changes..
Need your comments and suggestions.
Thnx |
|
|
jds-pic
Joined: 17 Sep 2003 Posts: 205
|
|
Posted: Mon Jan 17, 2005 9:12 am |
|
|
chingB wrote: | Even though I am using the PIC18F452, the problem is still there. What are the register necessary to be updated after bootloading the new firmware? |
see my post of Aug 23 2004 in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=20282
jds-pic |
|
|
chingB
Joined: 29 Dec 2003 Posts: 81
|
|
Posted: Sun Jan 23, 2005 7:23 am |
|
|
jds-pic wrote: | chingB wrote: | Even though I am using the PIC18F452, the problem is still there. What are the register necessary to be updated after bootloading the new firmware? |
see my post of Aug 23 2004 in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=20282
jds-pic |
I try the suggestion from this link and it workz... thank u jds-pic.
-- |
|
|
|