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.

C2000WARE: Infinite loop in library

Part Number: C2000WARE

Tool/software:

Customer noticed that infinite while loop is adopted in the library to wait for hardware status If there is fault in hardware, the firmware will be deadlock.  For Mission Critical Hard Real Time Embedded System, this is not a safe implementation. 

1. What is the recommend way to fix this for hard real time systems?

2. For C2000Ware roadmap, will there be plan to enhance this instead of using infinite loop?

Below are two examples in SCI and SPI. 

 

Location: driverlib of C2000Ware, version 5.0.0.00

Example #1 File name: sci.c: Function: SCI_readCharArray(uint32_t base, uint16_t * const array, uint16_t length)

 

Example #2: File name: spi.h: Function: SPI_writeDataBlockingFIFO(uint32_t base, uint16_t data)

  • Hi Eddie,
    The expert is currently out of the office and will get back to you when they are back. Thank you.

    Best Regards,

    Aishwarya

  • Hi Eddie,

    For the SCI_readCharArray() function, the recommended usage is to call this from a SCI RX ISR, in which case it won't be called unless the proper number of bytes are present in the RX FIFO (or in non-FIFO mode, at least one byte is present). This while loop is really only included for if users are doing a polling approach rather than an interrupt approach, which would not be recommended in time-critical systems.

    With the SPI_writeDataBlockingFIFO() function, this should never get stuck in an infinite loop. The while loop will wait until there is at least one spot available in the SPI TX FIFO. Since data is continuously shifted out of the TX FIFO, it will always eventually break out of this loop. In most cases, it should immediately break out of the loop. If they wanted to ensure this loop is never entered, they can call this function from a SPI TX ISR, that way it will only be called when the correct amount of FIFO spots is available to be written.

    For both of these cases, I don't believe there is a plan to change these while loops in the driverlib functions since it is important to block unwanted writes/reads to/from the FIFOs.

    Best Regards,

    Delaney

  • Hi Delaney,

    Thanks for your reply for this matter. I will feedback to customer. 

    Regards,

    John

  • Hi Ke,

    Sounds good, glad I could help. I will close this thread for now but feel free to make another if they have any more questions.

    Best Regards,

    Delaney