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.

TMS570LS3137: I would like to implement SPI communication using IRQ method using TMS570LS3137 and safeRTOS.

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN,

Dear All,

As the title says, I want to implement SPI communication in the TMS570 devkit. Could you please confirm if what I am doing is correct?

1.Driver INIT
- Halcogen -> TMS570LS3137ZWT Tab -> Driver Enable -> Enable SPI3 driver

2. SPI3 settings (8bit transmission)
- SPI3 Global Tab -> check Master Mode and Internal Clock
- SPI3 Data Formats Tab -> Data Format0 Charlen 8 settings
- SPI3 Port Tab -> SOMI output, SIMO input, CLK output, ENA input, SCS[0] output settings

3. IRQ settings
- TMS570LS3137ZWT Tab -> VIM channel 32-63 Tab -> 38:MIBSPI3 Level 1 Enable

4. Operation
- SPI Data Sending: spiInit(); -> spiEnableNotification(spiREG3, (uint32)((uint32)1U << 8U)); -> spiSendData(spiREG3, &dataconfig1, sizeof(cpuMessagebuf)/2, cpuMessagebuf);
- SPI Data Receive: Read data by executing mibspi3LowLevelInterrupt() -> spiNotification() -> spiGetData().

Is this how it works?
I will wait for advice from experts.

Best Regards,
IBLEE.

  • ah!!!

    Halcogen -> SPI3 Tab -> SPI Global Tab -> Set to Low Level.
    To get a LowLevel IRQ.

  • Hi IBLEE,

    2. SPI3 settings (8bit transmission)
    - SPI3 Global Tab -> check Master Mode and Internal Clock
    - SPI3 Data Formats Tab -> Data Format0 Charlen 8 settings
    - SPI3 Port Tab -> SOMI output, SIMO input, CLK output, ENA input, SCS[0] output settings

    If you want to operate the TMS570LS3137 in master mode, then

    SOMI (Slave Out Master In) should be input and SIMO (Slave In Master Out) should be output.

    4. Operation

    And also make sure to call the "_enable_IRQ();" after SPI initializations because by default IRQ interrupts will be in disabled state.

    Apart from these i don't see any other issues in your process.

    --
    Thanks & Regards,
    Jagadish.

  • Dear Jagadish.

    Thank you for checking.
    The reason it didn't work before may be because _enable_IRQ() was done before spiInit().
    I'll check again.
    thank you.

    Best Regards,
    IBLEE.

  • Dear Jagadish.

    When sending data from Master to Slave
    spiEnableNotification(spiREG3, (uint32)((uint32)1U << 8U));
    I ran it like this and ran spiSendData(); to send data.

    Why spiEnableNotification(spiREG3, (uint32)((uint32)1U << 8U)); If I put this code, will dataAbort occur in mibspi3LowLevelInterrupt()?

    Could you tell me what I'm doing wrong?

    Best Regards, 

    IBLEE

  • When the above dataAbort occurs, the g_spiPacket_t[2U].rxdata_ptr value is 0x00000000.
    So I think it's a problem,
    Is there anything I missed?

  • The above dataAbort occurs immediately when you press “go” in the main function after downloading.
    But what's even more strange is that the rx interrupt occurred even though the slave didn't even send data.
    I don't understand it with my common sense.
    Is there anyone who can help me?

  • Hi INBUM LEE,

    I am suspecting this:

    Maybe you enabled the RXINT and you are calling "spiSendData" function without calling the "spiGetData".

    As SPI communication is full duplex communication, that means if you are sending some data at the same time in parallel you will receive some data right.

    If you enabled RXINT function but you are not calling spiGetData function before you are calling "spiSendData" function then rxdata_ptr will be a null pointer and will have a zero address.

    So, whenever we receive parallel data which will get try to move to the null address and will create exception.

    You can do either of the below:

    1. If you don't want receive data from slave, don't enable the RX_INT.

    2. If you want receive data then please call spiGetData function before calling the spiSendData, so whatever the received data will be moved to the destbuff you are passing to the get data function.

    Or else simply call the "spiSendAndGetData" function, this function will take both source address for transmission and destination address for reception.

    --
    Thanks & regards,
    Jagadish.

  • I was surprised by your kindness.

    aha!

    Do I need to run spiGetData() first before executing spiSendData()?
    Otherwise, you need to run spiSendAndGetData() to register the receive buffer.

    then
    1. Execute spiGetData() to register the receive buffer
    2. Execute spiSendData() to transmit data from master to slave
    3. When data is sent from slave to master, is it stored in the receive buffer and the spiNotification() function is called?

    Best Regards,

    IBLEE

  • Do I need to run spiGetData() first before executing spiSendData()?
    Otherwise, you need to run spiSendAndGetData() to register the receive buffer.

    You are correct.

    1. Execute spiGetData() to register the receive buffer
    2. Execute spiSendData() to transmit data from master to slave
    3. When data is sent from slave to master, is it stored in the receive buffer and the spiNotification() function is called?

    Exactly.

  • Dear Jagadish.

    What I want to do is send data from the master to the slave, then do something else before receiving data from the slave, and then receive the received data through spiNotification when I receive data from the slave. That's why I keep talking about spiNotification. Is it possible?

  • Hi INBUM,

    In SPI, a slave device cannot initiate data transmission. Only master can initiate the communication. The slave can only send back data to the master when its selected (CS active) and the master begun data transfer.

    I want to do is send data from the master to the slave, then do something else before receiving data from the slave, and then receive the received data through spiNotification when I receive data from the slave. That's why I keep talking about spiNotification. Is it possible?

    After doing something else, you should need to send some dummy data (e.g. all 0x00) to initiate the communication and to receive the data from the slave device. Otherwise, slave cannot send any data to the master by itself.

    --
    Thanks & Regards,
    Jagadish.

  • Dear Jagadish.

    Is that what spi communication is like? So the communication flow I think is wrong? I think I'll have to find another way. thank you.

    If I have any questions, I'll ask again.

    Thanks & Regards,
    IBLEE