RM46L852: How to maintain SPI4 CS low between write and read operation.

Part Number: RM46L852
Other Parts Discussed in Thread: HALCOGEN

Tool/software:

Hi,

I'm trying to read data from a SPI flash using the SPI4 peripheral.

When controling the CS manually (with a gpio) everything is working well. But when I let the SPI4 peripheral control the gpio, I can't get a valid reading.

A simple example would be the JEDEC ID command:

spiBASE_t *base = spiREG4;
spiDAT1_t  data_format = {.CS_HOLD = true,
                          .WDEL = true,
                          .DFSEL = SPI_FMT_0,
                          .CSNR = SPI_CS_0};

uint16_t tx[10] = {JDEC_COMMAND};
uint16_t rx[10] = {0};
spiTransmitData(base, &data_format, 1, tx);
spiReceiveData(base, &data_format, 4, rx);

I suspect that the problems is that the CS is reset in between the Transmit and Receive operation.

How can I make sure CS is kept low?

Please note that I can't use spiTransmitAndReceiveData because I don't want to receive at the same time that I transmit.

Regards,

Gabriel

  • Ideally, I would like to have a function like:

    spiTransmitAndThenReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 srcblocksize, uint16 * srcbuff, uint32 destblocksize, uint16 * destbuff);

  • Hi Gabriel,

    Apologies for the delayed response.

    You can use spiTransmitData and spiReceiveData only, however in transmit API you should make sure to enable CS_HOLD bit.

    If you make above highlighted bit as 1 then CS will be in HOLD that means CS will not get high after transmission completes and it will be still in low only. And then you can call receive function to finish the job and make the CS high again.

    I mean use two data_format, in your case and make CS_HOLD high for transmission data format and make CS_HOLD low for receive data format and do the testing.

    --

    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for your answer.
    Because I needed a better control on the CS_HOLD and I needed to send u8 instead of u16, I decided to simply re-write the halcogen generated code.

    I will close this issue. Thanks again.