> When you power off & power on the circuit, Y goes to a high
> number (255?)
GPRs (general purpose registers) are not initialized by a power-on reset, so there's no telling what value a GPR (or your variable) will hold on power-up. This is volatile memory, and will lose whatever value it holds when power is removed.
> If Y = 001 or 005, I need it to be this number upon power-up
Your only option is some type of non-volatile memory.
As Steve mentioned, you can use WRITECODE/READCODE, but be careful using this. You can wear out FLASH program code memory pretty fast. Look in your datasheet for the typical erase/write cycle specifications for FLASH program memory. It's very limited.
If your variable changes only "1" time each second, and you're writing this new value to FLASH program code space, you'll have 86,400 writes in a single 24 hour period. You can wear out program code memory or EEPROM pretty fast depending on how often your variable changes.
Ramtron offers a line of high endurance FRAM memory ICs. These offer around 10 billion read/write cycles, and NoDelay write times, but you'll still want to limit your write frequency to some order of magnitude that doesn't wear out your non-volatile memory during the expected life of the product/project.




Bookmarks