Memory (Part 3)
“Flock of eeprom chips ”
As mentioned before, EEPROM (Electrically Erasable Programmable Read Only Memory) is one type of memory which is very suitable for storing data on some occasion which would be read back as much as we like. As we deal with rather limited micro-controllers, we will skip the families of EEPROM chips which data are addressed in parallel mode. In this mode, 8 bits arranged memories require 8 pins from the micro-controller which is too much pins consuming even though the gain in speed is noticeable. Instead, we will look after chips which data is addressed in serial mode. Mainly two types of serial communication protocols are available: SPI and I2C. Both have there advantages and draw backs. My preference goes to SPI in spite of the highest number of pin required. In absolute, SPI is faster and I use this protocol a lot in my applications. So let’s go for the 25LC series of SPI EEPROM. Coming next after the 25LC chips are the 25AA chips. They differ from their supply voltages:
- 25LCxxx: 2.5-5.5V
- 25AAxxx: 1.8-5.5V
Within the 25LC family, some references are getting obsolete and Microchip suggests to use the A versions instead. In most cases, the A version (e.g. 25LC640A) operate at higher speeds. Care shall be taken at the B versions which have a different meaning! B versions have something to do with the way data are arranged internally. In other words, you may read carefully the chip data sheets before trying to tweak the proposed code.
As usual I am proposing a fully featured library which will allow to run any from the 25LC080, 25LC080A, 25LC080B, 25LC160, 25LC160A, 25LC160B, 25LC320, 25LC320A, 25LC640, 25LC640A, 25LC128, 25LC256, 25LC512 and 25LC1024 chips. plainEEPROM_SPI will do all the fine tuning for you, provided you can read the name on the chip and pick the correct constant name from the list as explained in the user manual file. Each chip has its own properties in terms of: Full memory size, page size, address bytes and maximum clock frequency and PlainEEPROM_SPI will care about them. Next is a short recap of the chip properties
Reference | Max. Clock | Total size | Pages | Page size | Address bytes |
---|---|---|---|---|---|
25LC1024 | 20MHz | 1024Kb | 512 | 256 | 3 |
25LC512 | 20MHz | 512Kb | 512 | 128 | 2 |
25LC256 | 10MHz | 256Kb | 512 | 64 | 2 |
25LC128 | 10MHz | 128Kb | 256 | 64 | 2 |
25LC640A | 10MHz | 64Kb | 256 | 32 | 2 |
25LC640 | 2MHz | 64Kb | 256 | 32 | 2 |
25LC320A | 10MHz | 32Kb | 128 | 32 | 2 |
25LC320 | 2MHz | 32Kb | 128 | 32 | 2 |
25LC160B | 10MHz | 16Kb | 64 | 32 | 2 |
25LC160A | 10MHz | 16Kb | 128 | 16 | 2 |
25LC160 | 2MHz | 16Kb | 128 | 16 | 2 |
25LC080B | 10MHz | 8Kb | 32 | 32 | 2 |
25LC080A | 10MHz | 8Kb | 64 | 16 | 2 |
25LC080 | 10MHz | 8Kb | 64 | 16 | 2 |
Alike the most recent version of PlainSDC, PlainEEPROM_SPI is offering a set of easy to use functions which will allow to access any data at any address within the memory without the burden of memory pages.
ReadUInt8(address)
ReadUInt16(address)
ReadInt16(address)
ReadUInt32(address)
ReadInt32(address)
ReadFlt32(address)
ReadUInt8()
ReadUInt16()
ReadInt16()
ReadUInt32()
ReadInt32()
ReadFlt32()
WriteUInt8(data, address)
WriteUInt16(data, address)
WriteInt16(data, address)
WriteUInt32(data, address)
WriteInt32(data, address)
WriteFlt32(data, address)
WriteUInt8(data)
WriteUInt16(data)
WriteInt16(data)
WriteUInt32(data)
WriteInt32(data)
WriteFlt32(data)
Write and read functions are available with and without address setting. When the address argument is not set, the write or read functions are executed at the actual memory location. The value of this internally managed variable can be read or set using the ActualAddress() function form the next list.
ActualAddress()
ActualAddress(address)
Advanced user are welcome to use page oriented functions for some specific advanced programming.
ActualPage()
ActualPage(page)
Pages()
PageSize()
BufferPointer()
ClearBuffer()
ErasePage()
ErasePage(page)
EraseAll()
ReadPage()
ReadPage( page)
WritePage()
WritePage(page)