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: Master-Slave SPI communication

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am Using two TMS570LS0432 boards for Master-Slave SPI communication.

I configured both the boards in Halcogen as instructed https://e2e.ti.com/support/microcontrollers/hercules/f/312/t/731608?tisearch=e2e-sitesearch&keymatch=tms570%20spi

In Halcogen(Version: 40.06.00) new project window I have selected family: TMS57LS04x and Device: TMS57LS0432PZ


Master

  • Driver Enable: Select SPI1 Driver only*

  • SPI1 Global TAB: Enable RxINT

  • SPI1 Port TAB:

  • Uncheck SOMI Direction

  • Select SPI1 ENA GIO

  • Select SPI1 SCS[3] GIO

  • Select SPI1 SCS[2] GIO

  • Select SPI1 SCS[1] GIO

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



Slave

  • Driver Enable: Select SPI2 Driver only*

  • SPI1 Global TAB:

  • Unchecked Master Mode and Internal Clock.

  • Uncheck SPI2 SOMI Direction

  • Uncheck SPI2 CLK Direction

  • Uncheck SPI2 SCS[0] Direction

  • Make SPI2 SCS[3] GIO

  • Make SPI2 SCS[2] GIO

  • Make SPI2 SCS[1] GIO

  • VIM Channel 0-31 TAB: Enabled SPI2 Level 0 and Level 1.

Pin Connections

Mater(SPI1)                              Slave(SPI2)

J1.7 --> MIBSPI1CLK               J10.24 --> SPI2CLK
J10.16 --> MIBSPI1nCS[0]       J10.21 --> SPI2CS
J2.6 --> MIBSPI1SIMO             J10.23 --> SPI2SIMO
J2.7 --> MIBSPI1SOMI             J10.22 --> SPI2SOMI

J10.4 --> GND                          J10.4 --> GND

 

I'm ensuring slave is ready before master sends data.

Code for master:

#include "sys_common.h"
#include "system.h"
#include "spi.h"

#include "sys_common.h"

/* USER CODE BEGIN (1) */
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 };
/* USER CODE END */


/* USER CODE BEGIN (2) */
void delayms(uint16 ms);
/* USER CODE END */

int main(void)
{
/* USER CODE BEGIN (3) */
    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();

    while(1)
    {
        spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);
        delayms(2000);
    }
/* USER CODE END */
}


/* USER CODE BEGIN (4) */
void delayms(uint16 ms) {
volatile unsigned int delayval;
delayval = ms * 8400;   // 8400 are about 1ms
while(delayval--);
}
/* USER CODE END */

Code for slave:

#include "sys_common.h"
#include "system.h"
#include "spi.h"


/* Include Files */

/* USER CODE BEGIN (1) */
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 };
/* USER CODE END */



int main(void)
{
/* USER CODE BEGIN (3) */
    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);
/* USER CODE END */
}


I am attaching CCS Project with .dil and .hcg files

Master :0576.M_SPI1_TMS.zip

Slave :

0285.S_SPI2_TMS.zip