AnsweredAssumed Answered

SPI with EEPROM in MPC5744

Question asked by RAMANJINEYULU THOTA on Sep 20, 2016
Latest reply on Sep 6, 2017 by xusheng yu

Hi,

I am currently working on SPI with EEPROM but i am unable to write data to EEPROM.

Please see the below code and let me know any modifications is needed.

 

int8_t SpiEepWritePage(const EEP_FUNC_ADDR func_addr, const uint8_t * const content)

{

uint16_t phy_addr;

uint32_t i;

 

phy_addr = SpiEepConvert2PhyAddr(func_addr);//func_addr is structure with page number and offset

 

ASSERT_WR_ENABLE();

 

SpiEepSelectSlave(SIG_ASSERTED);//CS=0

SPIIfTransferByte(Eep_Spi_Chanl_No, EEP_INSTRUCT_WRITE);

SPIIfTransferByte(Eep_Spi_Chanl_No, ADDR_HIGH(phy_addr));

SPIIfTransferByte(Eep_Spi_Chanl_No, ADDR_LOW(phy_addr));

for (i = 0; i < EEP_PAGE_SIZE; i++)//128Bytes

{

SPIIfTransferByte(Eep_Spi_Chanl_No, (uint8_t)(*(uint8_t *)(content + i)));

}

SpiEepSelectSlave(SIG_NEGATED);//CS=1

 

/* Wait for completion of previous write cycle */

while (((EEP_STAT_REG)(SpiEepReadStatReg())).B.WIP);

 

ASSERT_WR_DISABLE();

 

return 1;

}

In the above code we are transferring data to DSPI2.

 

Can you please help on this.

 

Thanks in advance.

 

Thanks & Regards,

Ramanjineyulu.

Outcomes