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

Emulating PIC EEPROM "self write to ROM"

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








Emulating PIC EEPROM "self write to ROM"
PostPosted: Mon Feb 08, 2010 10:04 am     Reply with quote

Hi !


Many new PICs got no EEPROM, but they got so called "self write" function. So far, as I understand it is method to write data into PIC flash program memory (ROM). I've seen data sheets called emulating EEPROM, I may guess it is what it is called.

Feel free to correct me if I'm wrong, because I feel like it is new for me and I do not know much about it.

---------------------------
My application needs are: store setup data from UI (may get changed few times) to avoid setup data loss after power off.

- Where I can find good, well formed examples about writing and reading data to ROM.

- How I can allocate or isolate constant space in ROM for data.



Thank you in advance !
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Feb 08, 2010 10:45 am     Reply with quote

Quote:
good, well formed examples about writing and reading data to ROM

You're expecting quite a lot. You can find CCS C examples for bootloader applications. They involve erase_program_eeprom(),
write_program_memory() and read_program_memory(), which are also the basic operation when using program
flash for data storage.

If you also want to emulate writing of individual eeprom locations, you may want to read Microchip's AN1095 Emulating
Data EEPROM for PIC18 and PIC24
. In my opinion, it's a "good, well formed example", that can be basically ported
to CCS C, if you don't fear a little bit of assembler coding.
Ttelmah
Guest







PostPosted: Mon Feb 08, 2010 11:09 am     Reply with quote

Remember:
1) A 'const' value, is put into ROM for you.
2) You can find the real address of the actual data (as opposed to the loader code), with the 'label_address' function.
3) The basic program memory functions as Fvm says, are used in the standard bootloader code.
4) The addressmod operator, allows you to use sections of program memory, and automatically read/write variables stored here.
Remember though the 'write life' limitations of this memory...

Best Wishes
Guest








PostPosted: Mon Feb 08, 2010 11:38 am     Reply with quote

FvM and Ttelmah, Thank You very much !

So... Very Happy
It is very easy to speak from my point of view.
If i want to store 10 floating point variables (converted into 40 int8s), written into program code at the programming moment as "default values" into certain constant 40 addresses. After programming application user can change tease values at least 100 times ?


By using boot-loader application functions like:
write_program_memory( address, dataptr, count );
It could be done without big fuzz.

Btw. Does a boot-loader integration to a already written program require major changes in program ?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Feb 08, 2010 2:39 pm     Reply with quote

Quote:
Btw. Does a boot-loader integration to a already written program require major changes in program ?

You mean the real boot-loader function, not data storage in program memory? It's rather easy with PIC18,
that has only one common interrupt vector. It's done by adding a few preprocessor commands, freeing the
lower program memory for the boot-loader and redirecting interrupt and reset vectors. It's more complicated with
PIC24/dsPIC, because multiple interrupt vectors have to be relocated.
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