|
Re: read/write EEPROM on 18F8520
You can't put code in the EEPROM, there's no provision for executing it there. It's 1K of space where you can put "stuff" that you want to be there even after the power is turned off and back on. In that sense, it's not very different than program rom. The main distinction is that it's a little harder to read than data stored in program memory, but easier for your program to write.
To elaborate a bit on the sensor calibration, as an example of what the EEPROM is good for: We are building a prototype that has steering sensors on the wheels. The mechanical alignment of the sensors is hard to predict accurately, and likewise the proportional relationship between the sensor readout and the angular position is hard to know in advance. So we have a calibration routine that can be run at any time by a switch at the OI. During this calibration routine, the operator can put the wheels at several specific positions and "click" the joystick trigger to store the sensor reading at those positions in EEPROM. These readings are later used to interpolate the angle to a reasonable accuracy during regular operation of the 'bot.
A reasonable rule of thumb for the ram, program rom, and eeprom is:
- program rom for code, and for data known at compile time
- ram for read/write variables at run time
- eeprom for data that is determined at run time and needs to be stored permanently so it is known at next run of the 'bot
Hope this helps clarify.
Bill
|