Hi guys, I hope you can help me
I developed a multitasking application using MQX and a TWR-K60N512 evaluation board. The chip on the tower is a PK60N512VMD100 (0M33Z).
While I was working on the firmware, some collegues developed a custom board using MK60DN512ZVLQ10 (4N30D) chip which apparently seems to
be the same except for the presence of an internal DSP on the second one.
My application is made of 3 tasks. The init task is the auto start task and has a priority set to 9. It should run first and initialize the board. Before dying
it creates the other two tasks both with a priority of 10. They should run indefinitely.
When I use the tower everything is good. I can execute and debug the code (I'm using IAR and J-Link).
When I switch to the custom board I have many problems. Sometimes an error occurs when I try to upload the code so I need to erease all the memory
and try severl times before it stops tell me that the flash loader reported an error.
I don't know if this problem could be due to the linker file or the flash loader.
When I finally succed in uploading the code, something weird appens. I launch the debugger and I can see that the execution is stuck in "dispatch.s"
before the first task is scheduled.
The following code is copied by "dispatch.s" starting from line 432.
- ldr r2, [r1, #0] ; address of first td
- cmp r2, r1 ; ready_q structure itself?
- bne switch_task
- ldr r1, [r1, #RQ_NEXT_Q] ; try next queue
- movs r1, r1
- bne find_noempty_que
- ; r1 is 0 -> empty
- ; TODO set system task ???
- ; enable all interrupts (r1 = 0)
- ; TODO maybe (maybe not necessary) restore PendSV priority and BASEPRI after wfi
- msr BASEPRI, r1
- ldr r1, =0xE000ED20 ; SHPR3
- ldr r2, =0xff
- strb r2, [r1, #2]
- ; wait for interrupt
- cpsie.n i
- cpsid.n i
- ; TODO check r0, must be kernel data
- ldr r1, [r0, #KD_READY_Q_LIST] ; get first que from ready list
- b find_noempty_que
By now the line numbers I will use are the ones used in the following piece of code.
I found the pointer always at line 23. If I go step by step it reaches line 27, then jumps to line 1 and cycles in this function 15 times.
Then it goes on to line 9, 10, 11,.... until it come back to line 1 and repeat the cycle
NOTE: the custom board has been tested with other sample code, for example with a demo of FreeRTOS and works perfectly. When I try to upload
a demo of MQX (with multitasking) the result is the same: it stucks in dispatch.s, wheras the same code in the tower works perfectly.
If someone solved a similar problem before or has some advices to give, I will really appreciate it.
PS sorry for my English