Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] EEPROM Page shifting issue - from 1 page to next page

Status
Not open for further replies.

desgin

Full Member level 1
Joined
Apr 7, 2017
Messages
96
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
813
Hi
I am using EFM32 microcontroller.
Connected my external EEPROM through I2C.
EEPROM total pages are 512 and each page contains 256 bytes.

I need to move from 1 page to other page but its getting stuck.
Can anyone please help me!

Thanks in advance
Its bit urgent, please help me
 

Hi,

"but its getting stuck"
What is getting stuck? How did you test it?

I guess you did the "move" with the use of some software.
If so, then this software is the most probale cause of the problem.
Thus it´s urgent to show us your code.

Klaus
 

Hi,

"but its getting stuck"
What is getting stuck? How did you test it?

I guess you did the "move" with the use of some software.
If so, then this software is the most probale cause of the problem.
Thus it´s urgent to show us your code.

Klaus
Code:
void EEPROM_MultiByte_Write(uint32_t mem_addr, uint8_t pData[], uint16_t size)
{
    uint8_t device_addr_write, adress_to_write[2];

    init_I2C_EEPROM();
    delay_ms(5);
      if(mem_addr >= 0x10000){
        device_addr_write = EEPROM_I2C_HIGH_ADDRESS_WRITE;
      }else{ //memory address points to 00000h to 0FFFFh
        device_addr_write = EEPROM_I2C_LOW_ADDRESS_WRITE;
      }

      adress_to_write[0] = mem_addr>>8;
      adress_to_write[1] = mem_addr&0x00FF;

      EEPROM_Disable_Write_Protection();
      delay_ms(3);
      if(size <= 256){
          I2C_write_EEPROM((uint32_t)device_addr_write, &adress_to_write[0], &EEPROM_Write_data[0], 2, size);
      }
    else{
      uint16_t new_addr_AVG = mem_addr;
      uint8_t no_pages;
      for(no_pages = 0; no_pages < 2; no_pages++){
          new_addr_AVG = mem_addr + (no_pages * 256);
          adress_to_write[0] = new_addr_AVG >> 8;
          adress_to_write[1] = new_addr_AVG & 0x00FF;
          if(new_addr_AVG >= 0x10000){
            device_addr_write = EEPROM_I2C_HIGH_ADDRESS_WRITE;
          }
          else{
            device_addr_write = EEPROM_I2C_LOW_ADDRESS_WRITE;
          }
          I2C_write_EEPROM((uint32_t)device_addr_write, &adress_to_write[0], EEPROM_Write_data+(no_pages * 256), 2, 256);
      }
    }
      EEPROM_Enable_Write_Protection();
      delay_ms(2);

      I2C_Reset(I2C1);
      I2C1->ROUTEPEN = _I2C_ROUTEPEN_RESETVALUE;
      I2C1->ROUTELOC0 = _I2C_ROUTELOC0_RESETVALUE;
      CMU_ClockEnable(cmuClock_I2C1, false);
      delay_ms(2);
      GPIO_PinOutSet(EEPROM_SCL_PORT, EEPROM_SCL_PIN);
      delay_ms(1);
      GPIO_PinOutSet(EEPROM_SDA_PORT, EEPROM_SDA_PIN);
      delay_ms(2);
}
[moderator action: added CODE tags]
 
Last edited by a moderator:

Elementary EEPROM write action can't cross page boundaries. Does I2C_write_EEPROM() handle multiple page write? Probably not. In this case, it has to be partioned into multiple single page writes.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top