Good morning,
I have an RTOS with some simple tasks, in particular one is used to blinking some leds, and another to write on a serial port. The system work fine, but if I insert in the serial port task some instruction I have a system lock (indentified because the leds dont blink). In paricular this code work fine:
Then you should consider yourself lucky that it crashes right away. The sprintf() call is writing characters to a random place in memory – whatever testcar2 happens to point to, since you haven’t initialized it. On the ARM processors I’m familiar with, you might be getting a Data Abort exception for writing to non-existent memory. Or, if testcar2 happens to point to actual memory, then you might be trashing the stack of some other task.
Whatever the case, this code is wrong and should not work. If you replace the declaration of testcar2 with: