Part Number: TMS320F280023C
Other Parts Discussed in Thread: C2000WARE
Hello,
I'm facing an issue where my SPI writes fail when I add a line of code.
The hardware setup is an F280023 microcontroller interfaced to a DRV8304S that controls a BLDC motor. The registers in the IC are configured through SPI.
I cannot share the full code, unfortunately, but I can describe it and probably share some snippets. The int main() code structure is as follows:
- First there are some initialisation functions. The peripherals used are: timer0, timer1, ADC-A, ADC-C, SPI, SCI, and ePWM1/2/3.
- Then there is a main loop that essentially runs the motor in a few different "modes" (speed control, torque control, PWM control, etc). It's essentially one big switch-case in the main loop that controls execution flow.
- The interrupts that run regularly are:
- SCI interrupts for communication with another board.
- GPIO interrupts for commutation based on hall values coming from the motor.
- ADC interrupts which are triggered from the ePWM module (midpoint of PWM high) to sense phase currents.
When I add a line of code in main, then my SPI communications fail. Here are some observations:
- The line of code is not in the execution path of the code upon startup. It is in a section of code that is only accessed when I change a switch-case variable to enter a different execution path in the debug window. Still, the SPI communications that happen in the setup phase - before the switch-case is ever entered - seem to fail.
- On the oscilloscope, the MOSI line just shows seemingly random level changes. Photo attached below. This waveform repeats endlessly.

- It doesn't seem to matter what the line of code is. Whatever extra code is added seems to cause the issue. Specifically, I was trying to write into an array each loop to monitor the values of a particular variable, but even when I swapped out that statement for a normal addition statement with dummy variables or even duplicated the , the same failure condition arose.
- I thought it might be something to do with the stack/heap size, so I increased the memory allocated for those in CCS Linker options. Didn't solve the issue.
I understand this might be a vague description of the issue, even I'm trying to find out other useful clues. If I could get some pointers on other things I could look at to debug this, I would be very grateful.
Regards,
Vishnu
Edit: Some changes in the code occasionally produce a different sort of error - code freezes in the following area of boot ROM, which apparently happens if there is an illegal instruction trying to execute. It is still unclear what exactly causes this, since the code compiles just fine even when the error occurs.


