Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Wed Dec 01, 2010 8:24 am |
|
|
Several distinctly different routes/parts to this:
1) if you declare a variable in your code as 'const', this is stored in the flash for you, and automatically read by the compiler when you read it. The easiest route.
2) If this is a value you want to change, then consider putting it into the data EEPROM instead. The 'write life' of the flash, is only 1000 cycles on this chip, against 100K cycles for the EEPROM. Look at the read_eeprom and write_eeprom functions, and the notes with these about transferring values larger than a byte.
3) If you really 'must' write to the flash, and understand the write limitations, then look at the read_program_memory, and write_program memory functions, the overview of these, and the notes about them. Also the bootloader example, which (of course), uses these.
Best Wishes |
|