Is an I2C "flasher" possible

Hello. Me again :sweat_smile:

Is it possible to make the arduino act as a programmer for an LED driver via I2C. The data set is written in a Intel HEX format, example:

::0400000300010800F0 - 1)Start segment
:0200E700000710 - 2)Data record
:0200E8000041D5
:0200E900006CA9
:0200EA0000FC18
.
.
.
:00000001FF -3)End of file record

  1. Start Segment Address Record (Type 03) - A start segment address record marks the beginning of a new data block. All following data record en-tries till the next start segment belong to the same OTP area of a particular driver:

  1. Data record (Type 00) - A data record contains the data for a specific register address:

  1. End of File Record (Type 01)

The slave device I2C parameters:

Protocol features:

  • Frame based communication
  • 7 bit device address - Upper 2 bits used as device group selector, lower 5 as device address (1-31 bus slave devices possible)
  • 8 bit device internal memory address space

Also the I2C address for the 1st LED driver is 08 and it has 4 OTP areas 0-3

I hope I've provided enough info.

Now what I hope I understand is:

I'd need to include Wire.h

{
 Wire.beginTransmission(7_bit_address);
 Wire.write(0xE7); // move pointer to register address
 Wire.write(0x00); // send 1st byte
 Wire.write(0x07); // send 2nd byte
 Wire.endTransmission();
}

Now to get the 7_bit_address value I need to take the OTP area value (00 - 0 for the 1st OTP area) from the HEX file and the I2C value (01000 - 8 ). So the combined should be : 00|01000 (0 for OTP area | 8 for I2C address) -> 0001000 sent with Wire.beginTransmission(0001000);

Then the 1st Wire.write would send E7 (1st data record line from HEX) and then the 2nd and 3rd would send the 2 data bytes 00 and 07.

Then repeat this for every data line of the HEX file.

Hope I've managed to be clear enough in presenting my thoughts... almost midnight, time to sleep for 4 hours :fearful:

Thanks for any input & suggestions. :slight_smile:

Ok... just realised the Hex file is not standard. The data potrion is not to be read as 2 8-bit bytes, but rather as a 10 bit data word. Max value 3ff.

Is the data length variable in I2C? I thought it's only the addres frame with 7, 8 and 10 bit option...

Hello. Me again :sweat_smile:

As far as I know, the Arduino Wire library can not use 10-bit I2C addressing.
Everything else is possible (it depends on your programming skills):

  • Reading data from the Serial port or from a microSD card.
  • Extracting data from the HEX file.
  • Shifting and extracting bits and bytes.
  • Writing to I2C devices.

The Arduino Wire libray can write a maximum of 32 bytes for a single package when using an Arduino Uno. The Arduino Zero, MKR 1000, Due can do more.

When writing data, the register address is the first byte and there is also a CRC byte, then there are 30 bytes left for data.

Thanks for the repply.

The various info sources I got were pretty unclear... So I had to brute force some understanding of the matter regarding the LED driver and HEX file supplier... I2C is only 8 bit, the datasheet was written in a confusing manner - lost in translation maybe.

And yeah I noticed today that I forgot to add the checksum frame. Need to onform myself a bit more on how to calculate that and combine it for the CRC6 frame.

If my math is correct this time I'll ned 6 bytes for 1 reg - 2 for device and memory address, 2 for data and 2 checksum... let the adventure continue :slight_smile: