When testing start-up sequence, CVC fault light would go on randomly even though we weren't going into CVC fault state.
Behavior:
after unpredictable amount of time, CVC safety output would go low and trip shut-down circuit when testing in vehicle (startup branch)
when we paused debugger, program was continuously stuck in SPI interrupt routine
SPI RX flag was high
SPI io state was wait_for_next_transmission (so flag would not be cleared in PLC_routine)
the SPI interrupt seemed to be starving other tasks, preventing SPI transmission from executing properly
Solution: turned out to be PLC watchdog due to tasks being starved when program would get stuck in SPI interrupt. We think this happened because initiate_SPI_transmission would get interrupted before setting SPI state to wait_for_CLT (this is possible because it was being called inside a task). We addressed this by making the call to initiate_SPI_transmission a critical section.
Concerns: the PLC_task had the highest priority, so theoretically it shouldn't have been interrupted by another task, though it could have been interrupted by user-defined interrupts (CAN, SPI)
Must wait and see if this fixes the problem, seems to be working for now...
When testing start-up sequence, CVC fault light would go on randomly even though we weren't going into CVC fault state. Behavior:
Solution: turned out to be PLC watchdog due to tasks being starved when program would get stuck in SPI interrupt. We think this happened because initiate_SPI_transmission would get interrupted before setting SPI state to wait_for_CLT (this is possible because it was being called inside a task). We addressed this by making the call to initiate_SPI_transmission a critical section.
Concerns: the PLC_task had the highest priority, so theoretically it shouldn't have been interrupted by another task, though it could have been interrupted by user-defined interrupts (CAN, SPI)
Must wait and see if this fixes the problem, seems to be working for now...