cancel
Showing results for 
Search instead for 
Did you mean: 

M95M04-DR EEPROM roll-over issue

LPetr.1
Senior

I am working with the M95M04-DR eeprom. In my program, I must save logs of data inside the EEPROM memory. I wriite data in chunks of 25 bytes.

I have written 11 chunks of data ant noticed a problem. I have a function to read back multiple bytes of data :

void EEPROM_read_multiple_bytes(spi_device_handle_t spi,uint32_t start, uint32_t number,uint8_t* data_bufer){
 
  if( (start + number) > 512000 ){
 
    printf("EEPROM out of bounds \n");
 
    return;
 
  }
 
  while(EEPROM_check_if_busy(spi) != true){ // return true if flash is not busy
 
    vTaskDelay(10/portTICK_PERIOD_MS);
 
    //printf("waiting for busy flag to clear \n");
 
  }
 
  uint32_t length = number;
 
  spi_transaction_ext_t trans = {
 
    .base = {
 
      .flags = SPI_TRANS_VARIABLE_ADDR,
 
      .cmd = 0b00000011,
 
      .addr = (uint32_t)start,
 
      .rxlength = length*8,
 
      .rx_buffer = data_bufer,
 
    },
 
    .address_bits = 24,
 
  };
 
  
 
  spi_device_polling_transmit(spi, (spi_transaction_t*)&trans);
 
  data_bufer = (uint8_t*)trans.base.rx_buffer;
 
}

I write some sample data to my chunks, for example:

The first chunk will have 25 bytes all set 0

the second chunk will have 25 bytes all set to 1

the third chunk will have 25 bytes all set to 2 and so on...

I am able to read back chunks and the data seemed to be correct at first, but once I reach 256 address, I start to receive incorrect data.

In my main, I call the function:

  uint8_t data_holder[275];

  EEPROM_read_multiple_bytes(external_eeprom,25,275,data_holder);

  for(int i = 0; i <250;i++){

    printf("data_holder[%i]=%u \n",(25+i),data_holder[i]);

  }

Please note that I ignore first 25 bytes because they are used for something else in my program. I write chunks from starting address = 25; so if I write 10 chunks it will start at 25 and end at 275.

The data in serial monitor:

data_holder[25]=0 
 
data_holder[26]=0 
 
data_holder[27]=0
 
data_holder[28]=0
 
data_holder[29]=0
 
data_holder[30]=0
 
data_holder[31]=0
 
data_holder[32]=0
 
data_holder[33]=0
 
data_holder[34]=0
 
data_holder[35]=0
 
data_holder[36]=0
 
data_holder[37]=0
 
data_holder[38]=0
 
data_holder[39]=0
 
data_holder[40]=0
 
data_holder[41]=0
 
data_holder[42]=0
 
data_holder[43]=0
 
data_holder[44]=0
 
data_holder[45]=0
 
data_holder[46]=0
 
data_holder[47]=0
 
data_holder[48]=0
 
data_holder[49]=0
 
data_holder[50]=1 
 
data_holder[51]=1 
 
data_holder[52]=1
 
data_holder[53]=1
 
data_holder[54]=1
 
data_holder[55]=1
 
data_holder[56]=1
 
data_holder[57]=1
 
data_holder[58]=1
 
data_holder[59]=1
 
data_holder[60]=1
 
data_holder[61]=1
 
data_holder[62]=1
 
data_holder[63]=1
 
data_holder[64]=1
 
data_holder[65]=1
 
data_holder[66]=1
 
data_holder[67]=1
 
data_holder[68]=1
 
data_holder[69]=1
 
data_holder[70]=1
 
data_holder[71]=1 
 
data_holder[72]=1
 
data_holder[73]=1
 
data_holder[74]=1
 
data_holder[75]=2
 
data_holder[76]=2 
 
data_holder[77]=2 
 
data_holder[78]=2
 
data_holder[79]=2
 
data_holder[80]=2
 
data_holder[81]=2
 
data_holder[82]=2
 
data_holder[83]=2
 
data_holder[84]=2
 
data_holder[85]=2
 
data_holder[86]=2
 
data_holder[87]=2
 
data_holder[88]=2
 
data_holder[89]=2
 
data_holder[90]=2 
 
data_holder[91]=2
 
data_holder[92]=2
 
data_holder[93]=2
 
data_holder[94]=2
 
data_holder[95]=2
 
data_holder[96]=2
 
data_holder[97]=2
 
data_holder[98]=2
 
data_holder[99]=2
 
data_holder[100]=3
 
data_holder[101]=3 
 
data_holder[102]=3 
 
data_holder[103]=3
 
data_holder[104]=3
 
data_holder[105]=3
 
data_holder[106]=3
 
data_holder[107]=3
 
data_holder[108]=3
 
data_holder[109]=3
 
data_holder[110]=3
 
data_holder[111]=3
 
data_holder[112]=3
 
data_holder[113]=3
 
data_holder[114]=3
 
data_holder[115]=3
 
data_holder[116]=3
 
data_holder[117]=3
 
data_holder[118]=3
 
data_holder[119]=3
 
data_holder[120]=3
 
data_holder[121]=3
 
data_holder[122]=3
 
data_holder[123]=3
 
data_holder[124]=3
 
data_holder[125]=4
 
data_holder[126]=4 
 
data_holder[127]=4 
 
data_holder[128]=4
 
data_holder[129]=4
 
data_holder[130]=4
 
data_holder[131]=4
 
data_holder[132]=4
 
data_holder[133]=4
 
data_holder[134]=4
 
data_holder[135]=4
 
data_holder[136]=4
 
data_holder[137]=4
 
data_holder[138]=4
 
data_holder[139]=4
 
data_holder[140]=4
 
data_holder[141]=4
 
data_holder[142]=4
 
data_holder[143]=4
 
data_holder[144]=4
 
data_holder[145]=4
 
data_holder[146]=4
 
data_holder[147]=4
 
data_holder[148]=4
 
data_holder[149]=4
 
data_holder[150]=5 
 
data_holder[151]=5 
 
data_holder[152]=5
 
data_holder[153]=5
 
data_holder[154]=5
 
data_holder[155]=5
 
data_holder[156]=5
 
data_holder[157]=5
 
data_holder[158]=5
 
data_holder[159]=5
 
data_holder[160]=5
 
data_holder[161]=5
 
data_holder[162]=5
 
data_holder[163]=5
 
data_holder[164]=5
 
data_holder[165]=5
 
data_holder[166]=5
 
data_holder[167]=5
 
data_holder[168]=5
 
data_holder[169]=5
 
data_holder[170]=5
 
data_holder[171]=5
 
data_holder[172]=5
 
data_holder[173]=5
 
data_holder[174]=5 
 
data_holder[175]=6 
 
data_holder[176]=6
 
data_holder[177]=6
 
data_holder[178]=6
 
data_holder[179]=6
 
data_holder[180]=6
 
data_holder[181]=6
 
data_holder[182]=6
 
data_holder[183]=6
 
data_holder[184]=6
 
data_holder[185]=6
 
data_holder[186]=6
 
data_holder[187]=6
 
data_holder[188]=6
 
data_holder[189]=6
 
data_holder[190]=6
 
data_holder[191]=6 
 
data_holder[192]=6
 
data_holder[193]=6
 
data_holder[194]=6
 
data_holder[195]=6
 
data_holder[196]=6
 
data_holder[197]=6
 
data_holder[198]=6
 
data_holder[199]=6 
 
data_holder[200]=7
 
data_holder[201]=7
 
data_holder[202]=7
 
data_holder[203]=7
 
data_holder[204]=7
 
data_holder[205]=7
 
data_holder[206]=7
 
data_holder[207]=7
 
data_holder[208]=7
 
data_holder[209]=7
 
data_holder[210]=7
 
data_holder[211]=7
 
data_holder[212]=7
 
data_holder[213]=7
 
data_holder[214]=7
 
data_holder[215]=7
 
data_holder[216]=7
 
data_holder[217]=7 
 
data_holder[218]=7
 
data_holder[219]=7
 
data_holder[220]=7
 
data_holder[221]=7
 
data_holder[222]=7
 
data_holder[223]=7 
 
data_holder[224]=7 
 
data_holder[225]=8
 
data_holder[226]=8
 
data_holder[227]=8
 
data_holder[228]=8
 
data_holder[229]=8
 
data_holder[230]=8
 
data_holder[231]=8
 
data_holder[232]=8
 
data_holder[233]=8
 
data_holder[234]=8
 
data_holder[235]=8
 
data_holder[236]=8
 
data_holder[237]=8
 
data_holder[238]=8
 
data_holder[239]=8
 
data_holder[240]=8
 
data_holder[241]=8
 
data_holder[242]=8
 
data_holder[243]=8
 
data_holder[244]=8
 
data_holder[245]=8
 
data_holder[246]=8
 
data_holder[247]=8
 
data_holder[248]=8 
 
data_holder[249]=8 
 
data_holder[250]=9
 
data_holder[251]=9
 
data_holder[252]=9
 
data_holder[253]=9
 
data_holder[254]=9
 
data_holder[255]=9
 
data_holder[256]=255
 
data_holder[257]=255
 
data_holder[258]=255
 
data_holder[259]=255
 
data_holder[260]=255
 
data_holder[261]=255
 
data_holder[262]=255
 
data_holder[263]=255
 
data_holder[264]=255
 
data_holder[265]=255
 
data_holder[266]=255
 
data_holder[267]=255
 
data_holder[268]=255
 
data_holder[269]=255
 
data_holder[270]=255
 
data_holder[271]=255
 
data_holder[272]=255
 
data_holder[273]=255
 
data_holder[274]=255

What is a possible issue here?

2 REPLIES 2
S.Ma
Principal

In short, eeprom is a memory you write in pages. Check the chip spec. For exemple, 32 kbyte eeprom use 64 bytes pages from address 0x0000 to 0x003F, after writing incrementally, you must stop at the page end, wait the actual erase program cycle is done, then continue next page....

LPetr.1
Senior

I see. However this particular EEPROM is 512 bytes so it does not fully explain why I am not able to write anything above 256 in one command. I am still exploring what could be an issue here.