Fram writing 32 byte value

Hi, i have fuond a simple code write 16 byte value into a FRAM chip (fm24cl04b-g).
It work fine, but i have to write 32 byte value, can someone can help me?
I m a newbie :slight_smile:

EepromWrite(0x00, test);


void EepromWrite(uint8_t theMemoryAddress, uint16_t u16Byte) 
{

  uint8_t lowByte = ((u16Byte) & 0xFF);
 // Serial.println(lowByte);
  uint8_t highByte = ((u16Byte >> 8) & 0xFF);
  //Serial.println(highByte);
  
  Wire.beginTransmission(DEVICEADDRESS);
  Wire.write(theMemoryAddress);
  Wire.write(lowByte);
  Wire.write(highByte);
  Wire.endTransmission();

//----------------------------------------------------------------------------
Lettura:

rtest = EepromRead(0x00);


uint16_t EepromRead(uint8_t theMemoryAddress) 
{
Wire.beginTransmission(DEVICEADDRESS);
Wire.write(theMemoryAddress);
Wire.endTransmission();

Wire.requestFrom(DEVICEADDRESS,2);
uint8_t lowByte = Wire.read();
uint8_t highByte = Wire.read();


return ((lowByte) & 0xFF) + ((highByte << 8) & 0xFF00);
}

I Know that i have to split a 32 byte valur in 4 8 byte, but i don t know how ?

Thank you.
Regards

A lot like this using a Union

I d lile just modify my code...
by Union i don t see the way...

I m a litle newbie :slight_smile:

tmsio:
I d lile just modify my code...
by Union i don t see the way...

I m a litle newbie :slight_smile:

The link I gave you shows you how to take a four byte data type (could be a float, long or unsigned long) and break it into its constituent bytes, and vice-versa.

What did you try?

i m tryining :slight_smile:

post what you ave tried...

Another way is simple bit-shifting like this:

void setup() 
{
  Serial.begin(9600);
  unsigned long myFourByte = 0xA1B2C3D4;
  Serial.print("My four byte number: ");
  Serial.println(myFourByte, HEX);
  Serial.println("and each byte: ");
  for (int i = 0; i < 4; i++)
  {
    Serial.print("Byte ");
    Serial.print(i);
    Serial.print(": ");
    Serial.println((byte)(myFourByte >> i * 8), HEX);
  }
}
void loop(){}

outputs:

My four byte number: A1B2C3D4
and each byte: 
Byte 0: D4
Byte 1: C3
Byte 2: B2
Byte 3: A1