PDA

View Full Version : Quick question reguarding the eeprom write / read



grasshopper
01-23-2009, 12:37 AM
I noticed that the BS2 Object contains 3 types of write / reads. Could someone clarify the differences that each one offers.




Write(Addr,Value, size)
Write to EEPROM in code space, from top (32767) to bottom (0)
where 0 = top of memory

Write_HighMem(Addr,Value, size)
Write to upper 32K of 64K EEPROM
Write_HighMem(0,myVal,2) ' write byte variable myVal to upper 32K lowest address

Write_CodeMem(Addr,Value, size)
Write to direct code memory
Useful in having a variable survive a reset




From what I see Write just starts storing data from the top. Is this so that one wont over write the stack?

The other 2 methods I am not clear on. Currently I am using the Write_HighMem and it seems to work. I just want to learn more.

Mike Green
01-23-2009, 01:11 AM
It's fairly obvious if you look at the few lines of code involved. Write_HighMem just adds 32K to the address provided and Write just subtracts the address provided from $7FFF. Write_CodeMem doesn't change any of the parameters. If you're confused, strip out the comments for these routines from a copy of the BS2 object and you'll see how simple these routines are.

The stack only exists in the hub ram, not in the EEPROM, so the area in the EEPROM beyond the end of the program is not really used although it's cleared to zero when a new program is downloaded (to the end of the 1st 32K if the EEPROM is larger than 32K).