Hi
The most important things to know are the following:
1. You need to run the write/delete routines from RAM since the FLASH can not be accessed when being modified.
2. You can write bits from '1' to '0' on a
long word basis.
3. To set any bits from '0' to '1' you need to delete the 2k sector it is in.
4. Accesses to FLASH when programming is via their backdoor access address (study users' manual carefully for this)
You can use the following 2 routines from the uTasker project:
int fnWriteBytesFlash(unsigned char *ucDestination, unsigned char *ucData, MAX_FILE_LENGTH Length);this will write a buffer (ucData) of size Length (can also be one byte) to the address in internal FLASH (ucDestination). It handles long word alignment automatically.
int fnEraseFlashSector(unsigned char *ptrSector, MAX_FILE_LENGTH Length);This deletes the sectors occupied by the address ptrSector (can be anywhere in the first sector to delete) and over the length (Length). To delete the sector that an address is in set Length to 1 or to delete multiple sectros from the address set it to be a multiple 2k value.
These are all that you need (plus their subroutines which do the detailed work). The uTasker implements a parameter system which uses a swap buffer to allow a backup of old data to be restored if needed and also to ensure that parameter changes can not be corrupted if there is a power down during programming or deleting. If you have specific requirements for security it may be best to look at this but otherwise simply delete and write each time your parameter(s) change(s).
Regards
Mark
www.uTasker.com