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.

TMS570LS0432: SPI between two TMS570 Processors

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Hello,

I've tried the "example_spi_Master_Slave.c"  in a single LaunchXL board by using two SPI ports, and it worked.

Now I want to repeat the same study in two different LaunchXL boards. Basically I made same pin connections in different boards, I divide the halcogen configurations and the code (given in the example) for two boards. Although the example was working fine in a single board, it didn't work... I have an array of zeros in RX_Data_Salve register and 65535s in RX_Data_Master register.

Board one is set to be the master, using SPI1 and the second board is set to be the slave using SPI2 registers.

I'm giving my pin connections, halcogen configurations and codes below.

Thanks.

**********

I've made the pin connections as below:

 ---------------           ---------------
 SPI1 ( Master )     SPI2 ( Slave)
 ---------------           ---------------
 SIM0         --->      SIMO
 S0MI        <---       SOMI
 CLK          --->      CLK
 CS0          --->      CS0

**********I

n GUI configurations, in I've only selected SPI1 in Master board and left everything else as default.,

In slave board I've, 

  • Only selected SPI2 in Slave board,
  • Enabled SPI2 Level 0 and Level 1 channels in vim channels tab.
  • Unchecked Master Mode and Internal Clock in SPI2 global tab.
  • Uncheck DIR for CS 0 in SPI2 port tab.

*********

The code in master is this:

#include "sys_common.h"
#include "system.h"
#include "spi.h"
uint16 TX_Data_Master[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
uint16 RX_Data_Master[16] = { 0 };
void main(void)
{
    spiDAT1_t dataconfig1_t;
    dataconfig1_t.CS_HOLD = FALSE;
    dataconfig1_t.WDEL    = TRUE;
    dataconfig1_t.DFSEL   = SPI_FMT_0;
    dataconfig1_t.CSNR    = 0xFE;
    _enable_IRQ();
    spiInit();
    spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);
    while(1);
}
**********
And the code in the slave side is like this:
#include "sys_common.h"
#include "system.h"
#include "spi.h"
uint16 TX_Data_Slave[16] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 };
uint16 RX_Data_Slave[16] = { 0 };
void main(void)
{
    spiDAT1_t dataconfig1_t;
    dataconfig1_t.CS_HOLD = FALSE;
    dataconfig1_t.WDEL    = TRUE;
    dataconfig1_t.DFSEL   = SPI_FMT_0;
    dataconfig1_t.CSNR    = 0xFE;
    _enable_IRQ();
    spiInit();
    spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Slave, RX_Data_Slave);
    while(1);
**********
  • Hello,
    Could you check whether at Slave device in PINMUX Tab you have check SPI2 checkbox? If it is not checked it, please do it. Also check direction of all pins in SPI2-->SPI2 Port Tab,SPI2 SOMI should be output, SPI2 SIMO - Input, SPI2 CLK - Input, SPI CS0 - Input.

    Did you check whether Master is outputting data on the bus?

    Best regards,
    Miro

  • Hello Miro, thanks for your response.

    SP2 is checked in pinmux tab.

    Directions of the pins are like this:
    Master: SOMI in, SIMO out, CLK out, CS(0) out.
    Slave: SOMI out, SIMO in, CLK in, CS(0) in.

    I checked Master's output with a scope ans as far as i can see it is constant 3.3 V. Output of slave is 0 V.

    Regards.

    Turev.
  • Hello,
    Please check whether Slave is ready before Master sends data.
    You should view on the scope data has been sent from Master. If the scope is not capturing any signal from the Master, check settings on it.
    Could you send your HALCoGen projects (Master and Slave) so I can take a look on it?

    Best regards,
    Miro
  • 0638.SPI Master Slave.zipHello,

    I couldn't find how i can check the status of the slave? Also i guess i don't see any meaningful signals both from master or slave pins. By the way when i tried the Master-Slave example in a single board i didn't get any signals either. But the example was working an i could see the TX data in RX buffers.

    I include the .hcg files below.

    Regards,

    Turev

  • Hello,
    Which one is your HALCoGen version?
    After I open files you sent, I found many problems. Like both devices are set as a Master (and many other discrepancies). I wonder whether there is some problem with HALCoGen versions.

    Best regards,
    Miro
  • Hello,
    Could you attach *.dil files as well?

    Best regards,
    Miro
  • Hello,
    Did you make progress?

    Best regards,
    Miro
  • 8686.DILs.zipHello,

    I changed the code to send and receive data inside of the "while". Then i could see meaningful data signals. RX buffers are still same, one with  zeros and one with 0xFFFFs. Iguess the problem  may be about timing.

    My Halcogen version is 4.06.00. My Halcogen settings are the same with the one with the example but i'll check again. I'm attaching the .dils

    Regards.

    Turev

  • Hello Turev,
    I have opened HALCoGen projects you sent.
    Please check the following in you wiring (I suppose you are using two identical TMS570LS04x/03x LaunchPads) :
    Master:
    J1.7 --> MIBSPI1CLK
    J10.16 --> MIBSPI1nCS[0]
    J2.6 --> MIBSPI1SIMO - this function must be selected by J9
    J2.7 --> MIBSPI1SOMI - this function must be selected by J8

    Slave:
    J10.24 --> SPI2CLK
    J10.21 --> SPI2CS
    J10.23 --> SPI2SIMO
    J10.22 --> SPI2SOMI

    In HALCoGen do as follows:
    Master:
    SPI1 Global TAB
    Enable RxINT;

    SPI1 Port TAB:
    Make SPI1ENA GIO;
    Make SPI1SCS[3] GIO;
    Make SPI1SCS[2] GIO;
    Make SPI1SCS[1] GIO;

    VIM Channel 0-31 TAB
    Enable MIBSPI Level 0 & Level 1 Interrupts;


    Slave:
    SPI2 Global TAB:
    Enable RxINT;

    Make SPI2 SCS[3] GIO;
    Make SPI2 SCS[2] GIO;
    Make SPI2 SCS[1] GIO;

    After configuring HALCoGen and checking wiring, please make changes in your code to be sure that Master sends Data after Slave is ON and initialized. You can check whether button is pressed and then send data. If you use this approach take care on button bouncing. You can use ENA pin as well. Bu I prefer to start with button.

    At the osciloscope: You can trigger oscilloscope using falling edge of CS0 using single triggering mode.

    I hope this helps.

    Best regards,
    Miro
  • Thanks Miro,

    That's worked.

    Turev.