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.

CCS/TMS570LS1224: Working with SPI module

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN, TMS570LS0432

Tool/software: Code Composer Studio

Hello

I am working with a TMS570LS1224 microcontroller and need to send different kinds of packets of data via SPI module.My question is that how can I specify which data packet to use for a specific part of my code?

Also how can I make different data packets with different length and data type in halcogen?

  • hello Nika,

    The device supports 4 independent data word formats which allow configuration of individual data word length, polarity, phase, bit rate, etc. Each word transmitted can select witch data format to use via the bit DFSEL[1:0] in its control field of SPIDAT1.

    Data formats 0, 1, 2, and 3 can be configured through SPIFMTx control registers.

     \

    So you can select which format is used in your next transfer:

  • Thanks a lot QJ Wang

    In these settings why did you used SPI2 section?Is it different from SPI1 section? And also where did you mentioned to your code that you are using SPI2 not SPI1?

  • Hi Nika,

    Just an example. The data formats section is same for SPI1, SPI2,...MibSPI5.


    /* USER CODE BEGIN (2) */
    uint16 TX_Data_Master[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
    uint16 TX_Data_Slave[16] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 };
    uint16 RX_Data_Master[16] = { 0 };
    uint16 RX_Data_Slave[16] = { 0 };
    /* USER CODE END */

    void 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 CPU Interrupt through CPSR */
    _enable_IRQ();

    /* Initialize SPI Module Based on GUI configuration
    * SPI1 - Master ( SIMO, SOMI, CLK, CS0 )
    * SPI2 - Slave ( SIMO, SOMI, CLK, CS0 )
    * */
    spiInit();

    /* Initiate SPI2 Transmit and Receive through Interrupt Mode */
    spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Slave, RX_Data_Slave);

    /* Initiate SPI1 Transmit and Receive through Polling Mode*/
    spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);

    while(1);
    /* USER CODE END */
    }

    Please refer to the SPI master/slave example for TMS570LS0432.