I2c master and slave relationship

I am currently waiting on parts, so I don't have any code yet. The goal of my project it to program EEPROM of an arduino with a separate arduino. In this case the "master" is an Uno and the slave is the Adafruit Macropad. The macropad has 12 keys, an OLED display, a rotary encoder all with an I2C connector. For those concerned, I will be using a logic level converter as the Uno is 5V logic and the Macropad is 3.3V. Upon setup() the Uno will look to see if the Macropad is connected. If it is connected, it will enter into "programmer mode" that will allow the user to program into the uno the proper EEPROM bytes.

Inside "programmer mode", I would like the uno to request from the Macropad the proper byte setting for EEPROM_block1. I envision this would look like:

  1. Uno-->Macropad: Current EEPROM_block1 read is #. Requests an input for EEPROM_block1, acceptable range includes min_number_block1 to max_number_block2.

  2. Macropad: User types in a number on the macropad and presses send.

  3. Macropad-->Uno: The number between min_number_block1 to max_number_block2 is sent to the Uno.

  4. Uno: writes the received number in EEPROM_block1. It then reads EEPROM_block1 to verify proper write.

  5. Uno-->Macropad: Sends the EEPROM _block1 data to confirm

  6. Then loop 1-5 on EEPROM_block2 to EEPROM_blockN.

I anticipate approximately 10 bytes to program. Some of the writes may exceed 1 byte and therefore would include multiple bits.

My question is this: Does the Uno stay the master and the macropad the slave, or are they reversing roles multiple times between each EEPROM_block writes?

The master is the master all the time.

Can the Macropad be a slave or is it only a slave?

That needs to be;
Uno polls Macropad to see if any data is available.

A slave can't initiate a transfer.

The bos (master) is the one that generates the clock, the rest are slaves.

That needs to be;
Uno polls Macropad to see if any data is available.

A slave can't initiate a transfer.

So I think what is catching me up is that the data on the macropad doesn't exist for several seconds and only after the user types it in. An eternity for the uP...

The master can keep polling the slave, the wires won't wear out. Most of the time the slave might be saying "I got no data" and the master will need to try again.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.