Hi,
I’m developing a program for an MPC5744P using Simulink + Embedded Coder + Model Based Design Toolbox. I compile it with the S32DS compiler. I’ve been working in the model for a while now, and it has been working well so far.
However, I’ve had some problems in the last few days. I added some extra operations to an array, just one concatenation and a bitwise XOR of the elements of the array, nothing too complicated. It compiled well but when I tried to test it in HW, it seemed like nothing was being executed, or at least I wasn’t receiving anything through the CAN communications. I have been debugging using S32DS and iSystem’s BlueBox debugger, and I found the problem.
Usually, the program runs the initialization disassembly code and jumps to main(). In main(), it does an initialization first, and then configures the PIT Channel 0 interrupt, which is used to run the periodic task.
However, this behaviour changes with the last compilation. In the initialization disassembly code, in startup_MPC5744P.S, there is a line which seems to enable the interrupts:
wrteei 1 ;# Enable interrupts
As soon as this line is executed, the MCU launches the PIT Channel 0 interrupt Handle. This happens before the main() function is executed. Because of this, the periodic task is executed before the initialization, so it reaches a point where some variable is used before it is initialized and the program crashes.
The code that configures this interrupt is executed from main(), so I don’t know why it launches as soon as the interrupts are enabled in startup_MPC5744P.S. It is as if the interrupt remained configured from the previous execution. However, this never happened with previous compilations. As I said, the changes in the code don’t justify this change in the behaviour of the interrupts, nor in the Simulink model, nor in the C code.
Any tips on how to solve/debug this problem? I include the startup_MPC5744P.S file and the file containing the main().