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.

Chip selects for spi 2 on TMS570LS0332

Other Parts Discussed in Thread: HALCOGEN, TMS570LS0332

Hi,

I am using Halcogen 4.2, CCS6.1 and the TMS570LS0332.

 

I am trying to use CS 1 on SPI 2.

I enabled SPI 2 and I selected CS 1 on pin 12 on the pinmux tab.

 

However, I only see CS 0 on the SPI 2 port tab, and only code for CS 0 is generated.  How can I use CS 1 on SPI 2?

 

Thanks,

David

  • David,

    I see the same thing.  So while we can inquire - I think it is save to assume that the driver only supports a single chip select.

    You'll need to do some customization to expand it for more chip select.

    I would go ahead and use HalCoGen to:

     a) configure the extra chip select in the Pinmux tab

     b) configure the SPI2 for 4 pins (cs0).

    Then either modify the generated spiInit(), or call it first and then overwrite some register settings afterward.

    You will need to change the SCSFUN field of SPIPC0 from ending in 0x1 to 0x3 (for 2 chip selects).

    Also, You will need to make sure CSDEF reads 0xFF (which is the default) assuming your chip selects are both active low.

    It does look like the function spiTransmitAndReceiveData will support multiple chip selects, as it writes to SPIDAT1 (where you can specify a chip select) and the structure parameter 'dataconfig_t' is used to select the chip select.  (See lines 7 and 26 below)

    uint32 spiTransmitAndReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * srcbuff, uint16 * destbuff)
    {
        uint16 Tx_Data;
        uint32 Chip_Select_Hold = (dataconfig_t->CS_HOLD) ? 0x10000000U : 0U;
        uint32 WDelay = (dataconfig_t->WDEL) ? 0x04000000U : 0U;
        SPIDATAFMT_t DataFormat = dataconfig_t->DFSEL;
        uint8 ChipSelect = dataconfig_t->CSNR;
    
    /* USER CODE BEGIN (14) */
    /* USER CODE END */
        while(blocksize != 0U)
        {
            if((spi->FLG & 0x000000FFU) !=0U)
            {
               break;
            }
    
            if(blocksize == 1U)
            {
               Chip_Select_Hold = 0U;
            }
            /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
            Tx_Data = *srcbuff;
    
            spi->DAT1 =((uint32)DataFormat << 24U) |
                       ((uint32)ChipSelect << 16U) |
                       (WDelay)           |
                       (Chip_Select_Hold) |
                       (uint32)Tx_Data;
            /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
            srcbuff++;
    

  • Thanks for your help and the steps to work around it. It looks like it is also an issue on spi 3.

    Thanks,
    David