FlexCan with FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCan with FreeRTOS

608 Views
olesalscheider
Contributor I

Hi,

I'm trying to use FlexCan in interrupt mode together with FreeRTOS on the NXP GoldBox. More specifically I try to implement a simple interrupt-driven forwarding of CAN messages from CAN0 to CAN1 and the other way around. You can find the code attached.

My problem with this code is that it sometimes hangs in vListInsert inside the FreeRTOS code. You can easily reproduce this problem by (physically) connecting the FlexCAN0 and FlexCAN1 lines of the GoldBox, setting a breakpoint at line 235 in can.c and then executing the code. The debugger will stop a few times in line 235 and then execution will be stuck. When you pause execution, you will see the following stack trace:

Thread #1 1 [core: 0] (Suspended : Signal : SIGINT:Interrupt)
vListInsert() at list.c:150 0x340008ce
vTaskPlaceOnEventList() at tasks.c:3,075 0x34003fea
xQueueReceive() at queue.c:1,378 0x340012d4
CanFwdTask() at can.c:234 0x34006e00
pxPortInitialiseStack() at port.c:208 0x34005f80

I have seen the 4 common causes that are mentioned in the comment above (line 128f in list.c). But as far as I can tell none of the mentioned things happened. The stack and heap sizes are fine (and I increased them), I assign the lowest interrupt priority (0xf) to all interrupts in my main function, I only use ...FromISR API calls in my FlexCAN callback and I initialized the queues.

Do you see anything suspicious in my code, or is there maybe a bug somewhere in the RTD or FreeRTOS port? I am running out of ideas.

I have been trying to debug this for quite some time now but so far I could not find the problem. Any help would be really appreciated.

Thanks in advance!

Ole

0 Kudos
0 Replies