Prev: Software
Jolla and SailfishOS
The Other Half EEPROM programming using an Arduino Uno as In-System-Programmer
Proteus Simulation
Using the setup for Proteus shown in Fig. 1 we can verify the code in a simulation.
I used version 8.5 of Proteus with Basic Simulation and the Virtual System Modelling add-on for AVR, that allows one to run and debug an Arduino sketch directly on the simulated hardware.
Click on the image for a larger version.
Writing the EEPROM
The first four lines of the I2C Debugger show the programming of the EEPROM:
- The MCU (as the I2C master) sends the 8bit I2C write access address of the EEPROM over the bus:
S(tart) A0 (= 0x50(deviceAddress)<<1 + 0x00(W))
- The M24C01 EEPROM (as the I2C slave) responses with:
A(cknowledged)
- The MCU writes the 8bit address to write to:
00
- The EEPROM responses with:
A(cknowledged)
- Now the page content is send byte by byte by the MCU, each byte being acknowledged by the EEPROM:
A4 A 44 A 00 A ...
- After the 16th byte is send the MCU stops the transmission by sending the STOP signal:
P
This is the signal for the EEPROM to transfer the bytes received into it's internal buffer. In the worst case, according to the datasheet, that will take 10ms. - The MCU waits for 10ms.
- Steps 1..6 are repeated for the three following pages.
Reading the EEPROM
The next eight lines of the I2C debugger show the reading of the EEPROM.
First the address to read from is set:
- The MCU (as the I2C master) sends the 8bit I2C write access address of the EEPROM over the bus:
S(tart) A0 (0x50(deviceAddress)<<1 + 0x00(W))
- The M24C01 EEPROM (as the I2C slave) responses with:
A(cknowledged)
- The MCU writes the 8bit address to read from:
00
- The EEPROM responses with:
A(cknowledged)
- The MCU stoppes the transmission:
P
Then the data bytes are read:
- The MCU (as the I2C master) sends the 8bit I2C read access address of the EEPROM over the bus:
S(tart) A1 (0x50(deviceAddress)<<1 + 0x01(R))
- The M24C01 EEPROM (as the I2C slave) responses with:
A(cknowledged)
- The EEPROM now sends data bytes (internally incrementing the address), as long as the MCU acknowledges:
A4 A 44 A 00 A ...
- The MCU pretty prints the byte received to it's serial console ("Virtual Terminal").
- The 16th byte is NOT acknowledged by the MCU:
N(ot acknowledged)
This stops the EEPROM from sending another byte. - The MCU stoppes the transmission:
P
These two block are repeated for all three remaining pages.
Next: Experiment