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 support@ccsinfo.com

PIC18F458 and write_program_eeprom

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







PIC18F458 and write_program_eeprom
PostPosted: Fri Apr 30, 2004 4:44 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 30, 2004 5:01 pm     Reply with quote

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.
xav27
Guest







PostPosted: Sat May 01, 2004 2:35 am     Reply with quote

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.
xav27
Guest







Loader question
PostPosted: Tue May 04, 2004 7:26 am     Reply with quote

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
Guest








PostPosted: Tue May 04, 2004 7:56 am     Reply with quote

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