This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1237D5PM: SPI FLASH Read/write

Part Number: TM4C1237D5PM


Hi,

We are using TM4c1237 in our project and SPI flash is connected to the microcontroller.

We are able to read the chip ID or the manufcature ID from the SPI FLASH. But we are not able to read or write to the SPI FLASH.

This issue we are not sure what is being done wrong. Please help us resolve this issue.

Thank you,

Deepanraj

  • The information you have provided is not sufficient for me to provide any help. I suggest you use a logic analyzer to capture the SPI waveform and compare it to the examples in the data sheet for the SPI FLASH device you are trying to program.
  • I have not heard back from you. I assume you have resolved this issue. If not please reply to this post.
  • Hi Bob,

    Sorry for the delay,

    We where trying to solve this SPI read and write. According to the datasheet shared by the SPI FLASH vendor for byte programing we need to do at 50Mhz and for read we need to do at 25MHz.

    How do we set these frequency in the code.

    Thank you,
    Deepanraj.A
  • Hi Bob,

    Actually read from the SPI FLASH is proper. But writing to the SPI flash is not being done.

    According to the datasheet of the SPI FLASH vendor. It is provided that the during the write operation the CS pin must be made low and after the data is being written to the FLASH the CD pin must be turned high for the write to be successful.
    Before this process the write enable pin must be high.

    We are following the above process and we are not able to write onto the SPI FLASH.

    Thank you,
    Deepanraj.A
  • If you have verified using an oscilloscope or logic analyzer that the TM4C123 chip is providing the correct waveform to CS, Enable, SPICLK and SPIMO; then the issue is either in this unnamed SPI flash device or in the understanding of that device.
  • Hi Bob,

    Is there anything to do with the SSI_ADV_MODE_WRITE in TM4c123 chip.
    Do we need to manually configure any GPIO pin as output for the SPI to work properly in tm4c123

    Thank you,
    Deepanraj.A
  • The advanced modes of SSI are not supported on the TM4C123 parts, only on the TM4C129 parts. I don't have enough information to answer your second question. If you need to transfer more than one frame (16 bits) with the chip select low and then going high only after the last transfer, then you will need to implement that chip select with a GPIO function that is made low and high by software.

  • Hi Bob,

    Please check my SPI Init function if anything is wrong.

    void SPI_Init(void)
    {
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    ROM_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3); // manual CS
    ROM_GPIOPinConfigure(GPIO_PA4_SSI0RX);
    ROM_GPIOPinConfigure(GPIO_PA5_SSI0TX);
    ROM_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5); // GPIO_PIN_1
    // Configure for 4MHz SPI speed (80MHz/20=4)
    ROM_SSIConfigSetExpClk(SSI0_BASE, ROM_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,ROM_SysCtlClockGet() / 10, 8);
    ROM_SSIEnable(SSI0_BASE);
    uint32_t tmp;
    while (ROM_SSIDataGetNonBlocking(SSI0_BASE, &tmp));
    }

    Thank you,
    Deepanraj

  • Hi Bob,

    We are able write into the SPI FLASH.

    But when we try to read from the SPI Flash. Only the first byte is being read and the next byte is printed as 0xFF.

    We think like the address is not properly incremented in the ti provided API to read the SPI FLASH .

    Please help us resolve this issue.

    Thank you,
    Deepanraj
  • Which API function are you using that you suspect is not correct?

  • Hi Bob,

    We are suspecting the SPIFlashRead() API which is able to read only the first byte but the later bytes are being read as 0xFF.

    But during the write operation we have set breakpoint and checked the data which we are writing in is being written into the flash.

    Thank you,
    Deepanraj.A
  • Those functions use the SSI advanced mode which is not available on the TM4C123 devices. This post from another user may help:
    e2e.ti.com/.../501515