AnsweredAssumed Answered

MPC5748GRM SPI write EEPROM problem

Question asked by Haibin Wang on Sep 10, 2016
Latest reply on Sep 3, 2017 by xusheng yu

Hi all,


I am Wang Haibin from faladay future company. I have question on use spi to write EEPROM driver.


Now I am develop an spi driver to write EEPROM(M9501M-A125) on chip MPC5748GRM,   MPC5748GRM spi3 is master, EEPROM is slave.


the attachment is the EEPROM M9501M-125 specification




but when I try to write a byte to eeprom, there is no any feedback from the port MISO.


my port configuration is :


void init_spi3_ports(){


  /* Master - SPI_3 to configure to write eeprom */

SIUL2.MSCR[116].B.SSS = 2;                  /* Pad PH4: Source signal is SPI_3 SOUT  */

SIUL2.MSCR[116].B.OBE = 1u;                 /* Pad PH4: OBE=1. */

SIUL2.MSCR[116].B.SRC = 3;      /* Pad PH4: Full strength slew rate */


SIUL2.MSCR[117].B.IBE = 1;                 /* Pad PH5: Enable pad for input SPI_3 SIN */

SIUL2.IMCR[309].B.SSS = 1;    /* Pad PH5: Set as peripheral SPI3, MISO (SIN_3) - 821-512 */


SIUL2.MSCR[118].B.SSS = 2;                  /* Pad PH6: Source signal is SPI_3 SCK  */

SIUL2.MSCR[118].B.OBE = 1u;                 /* Pad PH6: OBE=1. */

SIUL2.MSCR[118].B.SRC = 3;                  /* Pad PH6: Full strength slew rate */


SIUL2.MSCR[119].B.SSS = 4;                  /* Pad PH7: Source signal is SPI_3 CS0_3  */

SIUL2.MSCR[119].B.OBE = 1u;                 /* Pad PH7: OBE=1. */

SIUL2.MSCR[119].B.SRC = 3;                  /* Pad PH7: Full strength slew rate */



Register configuration is:


void init_SPI_3(void) {

    SPI_3.MCR.R = 0x80010001;                 /* Configure SPI_3 as master,  SPI */

    SPI_3.MODE.CTAR[0].R = 0x38065522;   /1.25 MHz, 1 byte every frame size/

    SPI_3.MCR.B.HALT = 0x0;                   /* Exit HALT mode: go from STOPPED to RUNNING state*/



/function to write a byte/


static uint8_t Write_Byte(uint8_t cmd)



    uint16_t    response    = 0x0000;

    SPI_3.PUSHR.PUSHR.R = (uint32_t)((((uint32_t)cmd) & 0x000000FF) + 0x00010000);


    while (SPI_3.SR.B.RFDF != 1){}  /* Wait for Receive FIFO Drain Flag = 1 */

    response = (uint8_t)SPI_3.POPR.R;   /* Read data received by master SPI */

    SPI_3.SR.R = 0x80020000;


    return((uint8_t)((0x02 & response) >> 1));



/the function to write a byte to eeprom/


void EEPROMWriteByte(uint8_t Data, uint32_t Address)


SPI_Status_t spi3_status = 0;

    uint8_t* spi3_rx_byte = 0;

    uint8_t write_response;



    SPI_3.MCR.B.HALT = 0x0; /spi enable/

    write_response = Write_Byte(EEPROM_CMD_WREN); /eeprom write enable command/

    write_response = Write_Byte(EEPROM_CMD_WRITE); /eeprom write command/

    write_response = Write_Byte(Hi(Address)); /eeprom high address/

    write_response = Write_Byte(Mid(Address)); /eeprom middle address/

    write_response = Write_Byte(Lo(Address)); /eeprom low address/

    write_response = Write_Byte(Data); /a byte prepare to write to eeprom/

    while(EEPROMReadStatus().Bits.WIP); /read back the eeprom status/

    write_response = Write_Byte(EEPROM_CMD_WRDI); /eeprom rom write disable command/

    SPI_3.MCR.B.HALT = 0x1; /spi disable/



/the function of EEPROMWriteByte() is called in 10ms task/






EEPROMWriteByte(0x5A, 0x010011);






the debugger RxData register always is 0. the PORT MISO is alway in low voltage level.


it is my first to develop spi driver, maybe my question is too simple but it is realy puzzled me over 2 days, my question is follows:


1. whether  the enable port rise to high voltage is necessary after send one byte successfully?


2. How to differ the command, address, and data from the data transfer?


3. how to solve the promblem that MISO port is alway no any change, keep in low level voltage?




Do you mind to help me to solve the problem?


the following diagram show my puzzle:




channel 1 and channel 5 is HOLD and W protect pin in eeprom, already pulll up to battery.


Great thanks!


Wang Haibin