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.

TMS570LS1224: SPI communication receiving words with length > 16 bits

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am now working on a TMS570ls12X launchpad, equipped with the TMS570ls1224 microcontroller.

For the use of my application, I need to communicates with and 18 bits ADC (AD7608 )

I plan to connect it on SPI3 module (no mibSPI, no parallel : simple and classical spi). I can figure out how to physically connect it (MOSI, MISO, CLCK and CS), but I'm not sure on how to actually get the data

So i would like some answers on the following generalities :

- As the ADC sends 18 bits for each channel converted, how should I configure the SPI module as the maximum word length is 16 bits ? For exemple, Is it possible to set the framesize to 9bits read two words for each conversion (I suppose this would require some "continuous" reception configuration, like enable continuous reception, get first word, disable continuous reception while getting the second word and so on ?)

- Any exemple of halcogen configuration for this ?

I'm quite lost about this, and would really appreciate your help !

Regardly,

Audry

  • I forgot to mention the following informations :
    -the adc has no mosi line, so the cpu cant send nothing to it (not even "dummy transmit"), so how should i proceed to read data ?
    - according to the adc datasheet, it can only send "whole" data packets of 18bits ( possible to read all 144 bits for the 8 channels at once OR read 8×18bits data, but not less)
  • Hello Audry,

    You may try charlen=9 and blocksize=16 (8 channels * 2). The actual data for V1 channel is data[0] << 9 + data[1] (AD7608 is MSB).
  • Hello QJ,
    thanks for answering !
    Reading your answer, I assume that what to refer by "data" is a buffer of two 9bits buffers, right ? If so, I understand what you mean with data[0]<<9 + data[1], which is a 18bits register in correct order [msb....lsb], do you confirm ?
    However, in Halcogen, I do not have any "blocksize" parameter, only the "charlen" one... could you tell me what you mean by blocksize and how to configure it ?

    Thanks again

    Audry
  • Hello Audry,

    You are right. The data is 9-bit SPI received data: data[i]=spi->BUF; The data[0] and data[1] will be the data for your ADC channel0, data[2] and data[3] are for channel1, ...data[15] and data[16] are for channel 7.  

    The blocksize is the number of data you want to receive, it is 16 ( 9-bit * 16 = 18-bit/channel * 8 channels =144 bits data from ADC VI). The blocksize is defined is SW.

    In SPI configuration, please set CSHOLD=1, and WDELAY=0

    CSHOLD=1 means the chip select signal is held active at the end of a transfer until a control field with new data and control information is loaded into SPIDAT1.

  • Hello, and thanks for your support.

    I have tried today to set this communication using your help, but I'm getting confuse : in HalCogen, I can't set the CSHOLD pin... neither in ths SW. For what I found reading the datasheet, CSHOLD is only available with MibSPI and not simple SPI, right ?

    If so, I would like to know if you'll have some tutorials or explanation for me, about what is MibSPI, which differences with simple SPI, and how to configure it ? A simple exemple on my situation (need to read 16*9 bits of data, for 8*18 Vin) with HalCogen pictures and/or codes sample would be very nice ...

    I'm sorry to ask so much help, I'm not familiar with SPI and never heard of this MibSPI functionality :-(

    Thanks !

  • Hello Audry,

    The CSHOLD is 28th bit in SPIDAT1. It is enable/disable in SW, and the HALCoGen doesn't have the oprion for CSHOLD.The following example shows you how to enable the CSHOLD.

    /* USER CODE BEGIN (2) */

    uint16 RX_Data[18] = { 0 };

    /* USER CODE END */

    void main(void)

    {

    /* USER CODE BEGIN (3) */

    spiDAT1_t dataconfig1_t;

    dataconfig1_t.CS_HOLD = TRUE;

    dataconfig1_t.WDEL    = FALSE;

    dataconfig1_t.DFSEL   = SPI_FMT_0;

    dataconfig1_t.CSNR    = 0xFE;

    /* Enable CPU Interrupt through CPSR */

    //_enable_IRQ();

    /* Initialize SPI Module Based on GUI configuration

    * SPI2 - Slave  ( SIMO, SOMI, CLK, CS0 )

    * */

    spiInit();

    /* Initiate SPI2 Receive through polling Mode */

    spiReceiveData(spiREG2, &dataconfig1_t, 18, RX_Data);  //blcksize=18

    while(1);

    /* USER CODE END */

    }

  • Hello Qj,

    Thanks again ! I watched a video from TI on youtube, with it and your answers, I will give a hard try on make my communication work tomorrow !

    I'll let you know about how it goes.

    Thanks again

    Audry