Page 1 of 1

Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Thu Aug 13, 2020 4:43 pm
by JuanjoAlm
Im being introduced in a still developing project. The point is that they save a serial doing this:

Code: Select all
__prog__ char SERIAL[X]  __attribute__ ((space(XXX),section("XXX")));


And some settings using AN1095 (Emulating Data EEPROM).

¿What is the difference?

Re: Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Thu Aug 13, 2020 9:54 pm
by ric
What C compiler are you using?
What family of PIC devices?

Re: Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Fri Aug 14, 2020 9:00 pm
by jtemples
Given AN1095 and the use of __prog__ I'm guessing it's a PIC24 and XC16.

The declaration places the serial number at a specific address, and it will be part of the hex file that is programmed into the PIC rather than being written at run time.

AN1095 is a library that lets you write to flash at run time, simulating EEPROM on parts that don't have it (most PIC24s don't).

Re: Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Mon Aug 17, 2020 5:43 pm
by JuanjoAlm
Oh, thanks for the info!

Just one last question:

Why should I use a simulated library with a pic24fj512 wheter the program memory has a 10.000 erase/write cycle endurance? If my program just modifies that memory once a day.

Thanks for all!

Re: Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Mon Aug 17, 2020 7:03 pm
by jtemples
The library is just for convenience, saving you from having to write and test flash write routines.

Re: Simulated EEPROM and __attribute__ ((space(),section()))

PostPosted: Tue Aug 18, 2020 3:36 am
by AussieSusan
The (relatively) low erase/write cycle count in one reason why using the FLASH as EEPROM is probably not a good idea unless you really know what you are doing.
In general it is easier to get an external EEPROM and use that - they typically have erase/write cycle counts in the millions.
Also, depending on the amount of data you need to save and the write page size, there can be various techniques that let you erase a block and then write multiple times within that block which helps to extend the life of the EEPROM.
Susan