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.

SPI enters infinite loop, help needed

Other Parts Discussed in Thread: ADS1298

Dear friends,

I am trying to write a code to continuously read a data from a peripheral. I write the below code and during debugging the code loops in the highlighted "do while" loop forever. The CC bit never return to 1 in the SPISTAT1 register of the SPI. Any idea?

do { /* Check for busy result */
value=CSL_FEXT(CSL_SPI_REGS->SPISTAT1,SPI_SPISTAT1_BSY);
}while((value & 0x01) == 0x01);

CSL_FINS(CSL_SPI_REGS->SPICMD1,SPI_SPICMD1_FLEN,2);

CSL_FINS(CSL_SPI_REGS->SPIDR2,SPI_SPIDR2_DATA,0x0000);
CSL_FINS(CSL_SPI_REGS->SPIDR1,SPI_SPIDR1_DATA,0x0000);

CSL_FINS(CSL_SPI_REGS->SPICMD2,SPI_SPICMD2_CMD,0x71);

do { /* Check for Word Complete result */
value=CSL_FEXT(CSL_SPI_REGS->SPISTAT1,SPI_SPISTAT1_CC);
}while((value & 0x01) == 0x0); //waiting for CC=1

do { /* Check for busy result */
value=CSL_FEXT(CSL_SPI_REGS->SPISTAT1,SPI_SPISTAT1_BSY);
}while((value & 0x01) == 0x01);

SPI_read(hSpi ,spiReadPt, CSL_SPI_BUF_LEN);

Thanks in advance.
  • Hi,

    You may not be configuring the peripheral the way you expect to in your code. For example, in line 9 of your code where you set the 'SPI_SPICMD2_CMD' field in 'SPICMD2' register to read mode, you use a value of '0x71'. I assume you want to set the 'CLEN' field to '7'. But the 'CSL_FINS' macro only modifies the 'SPI_SPICMD2_CMD' field.


    If you have not already done so, please see the SPI example in Low-Power CSL package (...\C55 Low Power Chip Support Library v2.50.00\c55xx_csl\ccs_v4.0_examples\spi\CSL_SPI_Example) to see the steps required to properly configure the SPI. The example is to read from and write to a EEPROM. The steps are documented in the SPI User's Guide (spru317k.pdf). 

    Regards,

    Sunil Kamath

  • Hi,

    I was working on the example but CSL_SPI_EXAMPLE_OUT is a test project and it fails at the end. I write this situation in some topics but couldn't get an answer why it is failing. On the console view, all initialization, read, write, open, close, configure functions seems to be working. In this example 5515 writes a data block to EEPROM and tries to read it back. The test compares the written and read data and fails since the read and written data are different.

    By the way this is the only example that I have in CSL SPI library. Therefore, I do not have any reliable example or source to work on EVM5515 about SPI communication, this is shame.

    Regards,

    *** 

  • Sunil Kamath said:

    Hi,

    You may not be configuring the peripheral the way you expect to in your code. For example, in line 9 of your code where you set the 'SPI_SPICMD2_CMD' field in 'SPICMD2' register to read mode, you use a value of '0x71'. I assume you want to set the 'CLEN' field to '7'. But the 'CSL_FINS' macro only modifies the 'SPI_SPICMD2_CMD' field.


    If you have not already done so, please see the SPI example in Low-Power CSL package (...\C55 Low Power Chip Support Library v2.50.00\c55xx_csl\ccs_v4.0_examples\spi\CSL_SPI_Example) to see the steps required to properly configure the SPI. The example is to read from and write to a EEPROM. The steps are documented in the SPI User's Guide (spru317k.pdf). 

    Regards,

    Sunil Kamath

    By the way, I changed all these parts that you mentioned and tried to write the SPICMD2 data with all required fields and succeeded. However, this did not solve my problems. I also debugged the code coming with ADS1298 ECGSystem project. During debugging I observed that the program successfully reads and writes block of data to ADS1298. But when I use the same functions with the same configurations and put all these into a main function, it fails. What I mean by fails is I cannot read anything from SPIDR1 and SPIDR2 registers, they are always zero. 

  • I finally managed to work on SPI_Example, thank you for your effort.

  • Hi Ekrem,

                      i am having same problem what u had.. can u help me in the spi communication via J13 header in c5515 evm?