I'm seeing a very strange issue which I'm hoping someone can help me with. I have an application using FreeRTOS, and I'm able to create a repeatable crash. Here is the assembly code where my problem occurs (this happens to be in queue.c:prvUnlockQueue of FreeRTOS):
0x0CA68: C232 DINT
0x0CA6A: 4303 NOP
0x0CA6C: 5392 5BFE INC.W &usCriticalNesting
0x0CA70: 3C0B JMP (C$DW$L$prvUnlockQueue$13$E)
C$DW$L$prvUnlockQueue$11$B, C$L83:
0x0CA72: 0ACC MOVA R10,R12
0x0CA74: 00AC 0010 ADDA #0x00010,R12
0x0CA78: 13B0 CE0E CALLA #xTaskRemoveFromEventList
Based on the conditions of my program, I should never reach 0xCA72 (after the jump), and in fact I have verified that no C code executes which would lead it to that address. Curiously though, I will eventually end up there. Through some extensive debugging using the trace function and by moving the address of the usCriticalNesting variable, I am almost certain that for some reason the program is clobbering together the instructions at 0xCA6C and 0xCA70. The assembly view when looking at address 0xCA6E looks like the following:
0x0CA68: C232 DINT
0x0CA6A: 4303 NOP
0x0CA6C: 5392 5BFE INC.W &usCriticalNesting
0x0CA6E: 5BFE 3C0B ADD.B @R11+,0x3c0b(R14)
C$DW$L$prvUnlockQueue$11$B, C$L83:
0x0CA72: 0ACC MOVA R10,R12
0x0CA74: 00AC 0010 ADDA #0x00010,R12
0x0CA78: 13B0 CE0E CALLA #xTaskRemoveFromEventList
I believe this is essentially what is happening: Instead of using 0x5392 0x5BFE as an instruction (increment usCriticalNesting then jump), it is treating 0x5BFE 0x3C0B as an instruction (add bytes, no jump). When I do end up at 0xCA72, usCriticalNesting is 0, supporting the theory.
If I change the address of usCriticalNesting to 0x5A40, it changes the incorrect instruction to "ADD.B R10, PC", and my program ends up in no-mans land.
Any thoughts as to how/why this could be occurring? For reference, this is with an MSP430F5418a, using CCS4 v.4.2.4.00033, using v.3.3.3 of the code generation tools, large data & large code memory models.
Thanks!
-- Ryan