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 select on SPI1 on EVM C6748

Hi

I've been trying all day to get the SPI1 chip select line on the Logic EVM with C6748 SOM to something else than SPI1_SCS[0]. SPI1_SCS[0] is connected to the flash chip on the SOM, and I can see the chip select signal both on the flash chip and on connector J30 pin 93 on the base board. However, I don't quite understand how one should configure the device to use that (or another) chip select line.

From the C6748 BIOS PSP User Guide, I understand that the chipSelect element of the Spi_DataParam data structure selects the SCS pin, so chipSelect = 0 would select SCS[0], chipSelect = 1 would select SCS[1] etc. However, if I set chipSelect = 1, I see the chip select signal on SPI_SCS[0]. And if I set it to any other value, I cannot find the chip select signal anymore on connector J30 (or the flash chip).

 

Could anyone please educate me on what this chipSelect element exactly does and how to select a different chip select than SCS[0]?

For the record: I have the Logic EVM with C6748 SOM, psp drivers 01_30_00_05, BIOS 5.41.09.34 and edma3_lld_01_10_00_01 (at least, I think it is using that one). My SPI configuration is as follows:

Pinmux:

sysCfgRegs->PINMUX5 = 0x00111111u;
sysCfgRegs->PINMUX4 = 0x11111100u;

Spi_Params:

spiParams = Spi_PARAMS;
spiParams.hwiNumber = 8;
spiParams.spiHWCfgData.intrLevel = FALSE;
spiParams.opMode = Spi_OpMode_DMAINTERRUPT;
spiParams.outputClkFreq     = 1000000;
spiParams.loopbackEnabled   = FALSE;
spiParams.edmaHandle        = NULL;
spiParams.spiHWCfgData.pinOpModes = Spi_PinOpMode_SPISCS_4PIN;
spiParams.spiHWCfgData.configDatafmt[0].charLength   = 8;
spiParams.spiHWCfgData.configDatafmt[0].clkHigh      = TRUE ;
spiParams.spiHWCfgData.configDatafmt[0].lsbFirst     = FALSE;
spiParams.spiHWCfgData.configDatafmt[0].oddParity    = FALSE;
spiParams.spiHWCfgData.configDatafmt[0].parityEnable = FALSE ;
spiParams.spiHWCfgData.configDatafmt[0].phaseIn      = FALSE ;
spiParams.spiHWCfgData.configDatafmt[0].waitEnable   = FALSE;
spiParams.spiHWCfgData.configDatafmt[0].wDelay       = 0;
spiParams.spiHWCfgData.intrLevel     = TRUE;
spiParams.spiHWCfgData.csDefault = 1;

Spi_DataParam:

 

dataparam.bufLen       = SPI_MAX_CMD_LEN;
dataparam.inBuffer     = NULL;
dataparam.outBuffer    = &loopWrite[0];
dataparam.flags        = 1;
dataparam.dataFormat   = Spi_DataFormat_0;
dataparam.chipSelect   = 1;

Regards

Admar

  • Got it!

    The trick was to read the SPI register definitions carefully, especially wrt CSNR and CSDEF (SPRUFM4H: TMS320C674x SPI Users Guide, pages 44 and 51) as well as the spi.c source file from the psp spi driver.

    In short: with CSDEF you can set the status of each individual chip select line when there is no transaction happening. With CSNR you can set the status of each individual chip select line when there is a transaction happening. If you want chip select to stay active inbetween transactions, you'll also have to set CSHOLD.

    So, in case all spi devices are active low, set CSDEF to 0xFF. Then, to select the device connected to scs[0], set CSNR to 0xFE. For scs[1], set CSNR to 0xFD and for scs[2], set CSNR to 0xFB.

    The necessary changes to my code to select SCS[2] were:

    dataparam->chipSelect = (1 << 2);
    spiParams.spiHWCfgData.csDefault = 0xff;

    Admar

  • Thanks Admar for sharing your findings.  I was wondering if you know this - it seems like you'd be able to "broadcast" two two slaves by changing the chip select value to include two devices.  Would you agree with this or is it wishful thinking on my part? 

  • I apologize.  I should have done this test before I asked.  It appears that I can assert two chip selects with the same data to send the same command to two slaves simultaneously. 

  • On second thought this sounds like a bad idea because both slaves are going to be driving the MISO line during this time which would lead to bus contention.