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.

TMS320F280025: SPI code stuck issue

Part Number: TMS320F280025
Other Parts Discussed in Thread: C2000WARE

Hi Champ,

I am asking for my customer. They are copying our example code spi_ex6_eeprom to their own project.

Actually what they do is exactly the same procedure with our code in the main, only without the part of Wait until the EEPROM is ready to write data and check received data for correctness.

After enableWrite(), they directly write and read data from the EEPROM with below code, then go to while loop.

enableWrite(); 

writeData(EEPROM_ADDR, &TXbuff[0], 64, NO_DELAY);  // Write data to the EEPROM

readData(EEPROM_ADDR, &RXbuff[0], 64,NO_DELAY);  // Read from the EEPROM

while(1)

{

  customer's own application code

}

It is found that during debug mode,  the try to put a breakpoint before running to the first line of customer's own application code. 

While the code is stuck before the breakpoint, and stop at line 977 while((HWREGH(base + SPI_O_STS) & SPI_STS_INT_FLAG) == 0U) which is in the function of SPI_readDataBlockingNonFIFO in spi.h, and they will have to suspend and resume again, so that they could run to the breakpoint the first line in while loop. 

Would any expert clarify why the code is stop at here, and how to run to the first line in the while loop directly ?

Thanks and regards.

  • Hi,

    Can you provide some details on why the wait part was removed. This code basically checks the EEPROM status register and confirms that it is ready for writes

    Regards,

    Veena

  • Hi Veena,

    Here is more detail, I confirmed that the wait part was actually here in their code, the customer combined the wait part into the function of Write/Read data to the EEPROM. 

    We have found that after doing suspend and resume again, from the expression window, refresh the RXbuff, the RXbuff does receive the data actually. The situation is the same with trying on our example code, spi_ex6_eeprom.

    The customer would like to know why it stops at waiting for data to be received, and needed to resume again ?

    May I kindly have your comment ?

    Thanks for the help.

  • Hi Johnny,

    It could be a time delay related issue.

    Can you share the code snippet where they do the wait for EEPROM is ready before performing the read/write?

    Regards,

    Veena

  • Hi Veena,

    The customer has copied and pasted our example code (spi_ex6_eeprom), the problem is still there, also the time delay by interrupt is eliminated for sure.

    I am wondering if it is due to their hardware design. They are adding pull-up and pull-low resisters and 10 Ohm with the connection as below attached snippet. Would the time delay come from that ?

    Thanks and regards,

    Johnny

  • Hi Johnny,

    Let me pull in the hardware experts to help you further.

    Regards,

    Veena

  • Hi Veena,

    Thanks for your help. Looking forward to further help.

    Regards,

    Johnny

  • Hi Johnny,

    I don't think this issue should be related to hardware or the external pulls, schematic looks OK to me. They could try with a slower clock speed. What speed are they testing with now?

    We have found that after doing suspend and resume again, from the expression window, refresh the RXbuff, the RXbuff does receive the data actually. The situation is the same with trying on our example code, spi_ex6_eeprom.

    The customer would like to know why it stops at waiting for data to be received, and needed to resume again ?

    It seems some delay is necessary to read/write to the EEPROM, which is common when interfacing with an EEPROM (read / write cycle time). Can you provide a snipped of the code that they're having a question about?

    Best,

    Kevin

  • Hi Veena and Kevin,

    We figured out where is the problem. I think the function judges that the EEPROM unlock status bit condition is wrongly written.

    Line 170 in spi_ex6_eeprom.c is originally written in "while((readStatusRegister(RDSR) & MSG_STATUS_WRITE_READY_M) == MSG_STATUS_WRITE_READY_M){}", while we changed to "while((readStatusRegister(RDSR) & MSG_STATUS_WRITE_READY_M) == 0){}". Then, it is fixed.

    Thanks for your help on this.

    Regards,

    Johnny

  • Thank you for the details. We will check the C2000ware example and update accordingly.

    Thanks and Regards,

    Veena