Prev: Software

Jolla and SailfishOS

The Other Half EEPROM programming using an Arduino Uno as In-System-Programmer

2016-08-23 09:37

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:

  1. 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))
  2. The M24C01 EEPROM (as the I2C slave) responses with: A(cknowledged)
  3. The MCU writes the 8bit address to write to: 00
  4. The EEPROM responses with: A(cknowledged)
  5. 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 ...
  6. 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.
  7. The MCU waits for 10ms.
  8. 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:

  1. 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))
  2. The M24C01 EEPROM (as the I2C slave) responses with: A(cknowledged)
  3. The MCU writes the 8bit address to read from: 00
  4. The EEPROM responses with: A(cknowledged)
  5. The MCU stoppes the transmission: P

Then the data bytes are read:

  1. 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))
  2. The M24C01 EEPROM (as the I2C slave) responses with: A(cknowledged)
  3. The EEPROM now sends data bytes (internally incrementing the address), as long as the MCU acknowledges: A4 A 44 A 00 A ...
  4. The MCU pretty prints the byte received to it's serial console ("Virtual Terminal").
  5. The 16th byte is NOT acknowledged by the MCU: N(ot acknowledged)
    This stops the EEPROM from sending another byte.
  6. The MCU stoppes the transmission: P

These two block are repeated for all three remaining pages.

Next: Experiment