Not able to read data from IS25LP128F SPI Flash Memory to the STM32F05 SPI 2 peripheral

-1

It's the first time I try to use the SPI protocol with Flash memory.

Write Program function code:

void Flash_Write_Data(void)
{
    uint8_t Write_Enable = 0x06;
    uint8_t Page_Program = 0x02;
    uint32_t Address = 0x00000000;
        uint8_t addrLow = Address & 0xFF;
        uint8_t addrMiddle = (Address >> 8);
        uint8_t addrHigh = (Address >> 16);


        uint8_t Address_buffer[3] = {addrHigh,addrMiddle, addrLow}; 


    uint8_t txData[10] = {0xAB, 0x04, 0x06, 0xC7, 0x04, 0x90, 0x00, 0x00, 0x00, 0x00};

    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_RESET);    // CS to low
    HAL_SPI_Transmit(&hspi2,&Write_Enable,1,1000); // Write Enable Command
    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_SET);      // CS to high

    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_RESET);   // CS to low
    HAL_SPI_Transmit(&hspi2,&Page_Program,1,1000);// Page Program Command
    HAL_SPI_Transmit(&hspi2,Address_buffer,3,1000);     // Write Address ( The first address of flash module is 0x00000000 )
    HAL_SPI_Transmit(&hspi2,&txData[0],1,1000);      // Write 1  byte
    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_SET);      // CS to high
}

Read Program function Code:

void Flash_Read_Data (void)
{

        uint8_t Read_Data = 0x03;
    uint32_t Address = 0x00000000;
        uint8_t addrLow = Address & 0xFF;
        uint8_t addrMiddle = (Address >> 8);
        uint8_t addrHigh = (Address >> 16);
        uint8_t dummy_Data = 0;


        uint8_t Address_buffer[3] = {addrHigh,addrMiddle, addrLow}; 

    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_RESET);   // CS low
    HAL_SPI_Transmit(&hspi2,&Read_Data,1,1000);  // Read Command
    HAL_SPI_Transmit(&hspi2,Address_buffer,3,1000);     // Write Address ( The first address of flash module is 0x00000000 )

        //      HAL_SPI_TransmitReceive(&hspi2,&dummy_Data,RxData1,1,1000);      // Read 1 byte

    HAL_SPI_Receive(&hspi2,RxData1,1,10000);      // Read 1 byte
    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_SET);      // CS to high
}

Erase Program function Code:

void Flash_Erase_Chip(void)
{
    uint8_t Write_Enable = 0x06;
    uint8_t Erase_Chip = 0xC7;

    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_RESET);     // CS to low
    HAL_SPI_Transmit(&hspi2,&Write_Enable,1,1000); // Write Enable Command
    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_SET);      // CS to high

    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_RESET);     // CS to low
    HAL_SPI_Transmit(&hspi2,&Erase_Chip,1,1000);   // Erase Chip Command
    HAL_GPIO_WritePin(ASIF_GPIO_Port,ASIF_Pin,GPIO_PIN_SET);     // CS to high
}

Main function code:

HAL_GPIO_WritePin(ASIF_GPIO_Port, ASIF_Pin, GPIO_PIN_SET); //CE#

HAL_GPIO_WritePin(WP_GPIO_Port, WP_Pin, GPIO_PIN_SET); //Write Protection Pin

HAL_GPIO_WritePin(HR_GPIO_Port, HR_Pin, GPIO_PIN_SET); //Hold REset Pin

Flash_Erase_Chip();


HAL_Delay(3);  //3ms Delay
Flash_Write_Data();             
HAL_Delay(1);  //1ms Delay
Flash_Read_Data();


See full image here:

After sending the Read Command 0x3h the MISO slave pin is in High Impedance state always (No Response) using logic analyser.

I'm in the impression that write data is working perfectly please let me know if not.

Help me to resolve the issue. Thanks in advance.

Murali

spi
flash-memory
eeprom
stm32f0
asked on Stack Overflow Mar 6, 2019 by ping2murali • edited Mar 8, 2019 by VC.One

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0