![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
xav27 Guest
|
PIC18F458 and write_program_eeprom |
Posted: Fri Apr 30, 2004 4:44 pm |
|
|
Hello everybody,
I've read many post before posting my question, and I didn't find the same problem
I have : PIC18F458, CCS V3.187 and ICD-S
I'm using loader.c to update a part of my code (some constantes)
The loader is working fine except when I want to send just a portion of my code.
Here is a little part of my code :
#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOCPD,NOLVP
...
#org 0x3F0,0x410 {} // Reserve some place for CONST
#define CONST 0x3F0
...
#include <loader.c>
...
main()
{
// Print CONST area
addr = CONST_ADD;
for (i=0;i<8;i++)
{
valeur = (int16)read_program_eeprom(addr);
printf("%U ",valeur);
addr+=2;
}
...
load_program();
...
while(true);
}
// Const area to be changed via loader and PC program
#ROM CONST = { 1,0,144,148,4,20,15,89}
//-------END---------
If I send the following hex file, it does'nt works ! (some strange reactions)
:1003F000030000008000800004000A0025001C00AB
:00000001FF
;PIC18F458
This is certainly due to the fact that write_program_eeprom() can't do programming byte per byte (FLASH_ERASE_SIZE = 64) and the loader do a erase_program_eeprom just before writing into program eeprom ?!
Is there a way to make it works ?
Hope I was clear enough.
Thanks in advance for all
Xavier |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 30, 2004 5:01 pm |
|
|
Quote: | #define CONST 0x3F0 |
If I compile your test program, I get a "Duplicate #define" error
from the compiler. The reason is because CONST is a keyword. |
|
![](templates/subSilver/images/spacer.gif) |
xav27 Guest
|
|
Posted: Sat May 01, 2004 2:35 am |
|
|
Hi, PCM programmer
When I post the part of my code I've made little change to be more readable . In fact this is : #define CONST_ADD 0x3F0
I've read in the manual (July 2003) page 90 : (FLASH_ERASE_SIZE)
"For example, if it is 64 bytes then the least significant 6 bits of address is ignored."
If I well understand this mean that loader will erase a block add from 0x3C0 to 0x3FF . So I'll have to program this area ?
What can I do ?
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
xav27 Guest
|
Loader question |
Posted: Tue May 04, 2004 7:26 am |
|
|
Ni,
Still no answer to my question ! (and did'nt find to do it by myself)
Another way to explain my aim :
Is it possible to send via PC to a PIC using loader only 1 line (hex file format) ???
for example:
:1003F000030000008000800004000A0025001C00AB
:00000001FF
(the second line is necesary to resut the PIC and take change data)
For the moment i can't, and this is probably because the loader routine erase an entire bloc (FLASH_ERASE_SIZE=64)
Is there another way do do it ?
Thank's in advance
Xavier |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue May 04, 2004 7:56 am |
|
|
What you have to do is:
1) Read and store the contents of the entire block (64 bytes) in an array
2) Change the bytes you wich to change
3) Erase the block
4) Reprogram the block from the array |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|