i.MX8QM Cortex-M FLEXCAN FreeRTOS

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

i.MX8QM Cortex-M FLEXCAN FreeRTOS

Jump to solution
1,140 Views
io
Contributor II

Hello,
I’m working with i.MX8QM Cortex-M4 running FreeRTOS.
I use the NXP FlexCAN driver with interrupt callback. Inside the callback I try to call xSemaphoreGiveFromISR(), but the program always hangs/stuck at that point.

I already tried changing interrupt priority and checked FreeRTOS config, but still same result.
Does anyone have a simple example how to use FlexCAN with FreeRTOS task (semaphore or task notify) on i.MX8QM?

Here is my main program.
https://pastebin.com/BrhXQC1w 

Thanks.

Tags (3)
0 Kudos
Reply
1 Solution
1,062 Views
io
Contributor II

Just wanna share for anyone who may need it.

The problem was just the interrupt setup. I wrongly set the NVIC Priority
NVIC_SetPriority(DMA_FLEXCAN0_INT_IRQn, 3); which should be NVIC_SetPriority(IRQSTEER_4_IRQn, 3);

The FLEXCAN0 interrupt was connected to IRQSTEER_4_IRQn. Because the interrupt priority was wrongly set, it defaulted to a high priority (maybe 0). Then when calling xSemaphoreGiveFromISR() inside isr flexcan_callback, it causing the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() failure and the program to stuck there.

Ref:
https://community.nxp.com/t5/i-MX-Processors/imx8qm-IRQSTEER-interrupt-mapping/m-p/1067519/highlight...

https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ARM-Cortex/RTOS-Corte...

 

Regards,

io

View solution in original post

0 Kudos
Reply
2 Replies
1,063 Views
io
Contributor II

Just wanna share for anyone who may need it.

The problem was just the interrupt setup. I wrongly set the NVIC Priority
NVIC_SetPriority(DMA_FLEXCAN0_INT_IRQn, 3); which should be NVIC_SetPriority(IRQSTEER_4_IRQn, 3);

The FLEXCAN0 interrupt was connected to IRQSTEER_4_IRQn. Because the interrupt priority was wrongly set, it defaulted to a high priority (maybe 0). Then when calling xSemaphoreGiveFromISR() inside isr flexcan_callback, it causing the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() failure and the program to stuck there.

Ref:
https://community.nxp.com/t5/i-MX-Processors/imx8qm-IRQSTEER-interrupt-mapping/m-p/1067519/highlight...

https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/ARM-Cortex/RTOS-Corte...

 

Regards,

io

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2175915%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ei.MX8QM%20Cortex-M%20FLEXCAN%20FreeRTOS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2175915%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3CBR%20%2F%3EI%E2%80%99m%20working%20with%20i.MX8QM%20Cortex-M4%20running%20FreeRTOS.%3CBR%20%2F%3EI%20use%20the%20NXP%20FlexCAN%20driver%20with%20interrupt%20callback.%20Inside%20the%20callback%20I%20try%20to%20call%20xSemaphoreGiveFromISR()%2C%20but%20the%20program%20always%20hangs%2Fstuck%20at%20that%20point.%3C%2FP%3E%3CP%3EI%20already%20tried%20changing%20interrupt%20priority%20and%20checked%20FreeRTOS%20config%2C%20but%20still%20same%20result.%3CBR%20%2F%3EDoes%20anyone%20have%20a%20simple%20example%20how%20to%20use%20FlexCAN%20with%20FreeRTOS%20task%20(semaphore%20or%20task%20notify)%20on%20i.MX8QM%3F%3C%2FP%3E%3CP%3EHere%20is%20my%20main%20program.%3CBR%20%2F%3E%3CA%20title%3D%22flexcan_rtos%22%20href%3D%22https%3A%2F%2Fpastebin.com%2FBrhXQC1w%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpastebin.com%2FBrhXQC1w%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2175915%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2178167%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i.MX8QM%20Cortex-M%20FLEXCAN%20FreeRTOS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2178167%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJust%20wanna%20share%20for%20anyone%20who%20may%20need%20it.%3C%2FP%3E%3CP%3EThe%20problem%20was%20just%20the%20interrupt%20setup.%20I%20wrongly%20set%20the%20NVIC%20Priority%3CBR%20%2F%3ENVIC_SetPriority(DMA_FLEXCAN0_INT_IRQn%2C%203)%3B%20which%20should%20be%20NVIC_SetPriority(IRQSTEER_4_IRQn%2C%203)%3B%3C%2FP%3E%3CP%3EThe%20%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EFLEXCAN0%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%20interrupt%20was%20connected%20to%20%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EIRQSTEER_4_IRQn%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E.%20Because%20the%20interrupt%20priority%26nbsp%3Bwas%20wrongly%20set%2C%20it%20defaulted%20to%20a%20high%20priority%20(maybe%26nbsp%3B%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E0)%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E.%20Then%20when%20calling%26nbsp%3B%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3ExSemaphoreGiveFromISR()%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%26nbsp%3Binside%20isr%20flexcan_callback%2C%20it%20causing%20the%20%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EportASSERT_IF_INTERRUPT_PRIORITY_INVALID()%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%20failure%20and%20the%20program%20to%20stuck%20there.%3C%2FP%3E%3CP%3ERef%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors%2Fimx8qm-IRQSTEER-interrupt-mapping%2Fm-p%2F1067519%2Fhighlight%2Ftrue%23M156853%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors%2Fimx8qm-IRQSTEER-interrupt-mapping%2Fm-p%2F1067519%2Fhighlight%2Ftrue%23M156853%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.freertos.org%2FDocumentation%2F02-Kernel%2F03-Supported-devices%2F04-Demos%2FARM-Cortex%2FRTOS-Cortex-M3-M4%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fwww.freertos.org%2FDocumentation%2F02-Kernel%2F03-Supported-devices%2F04-Demos%2FARM-Cortex%2FRTOS-Cortex-M3-M4%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3Eio%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2177512%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i.MX8QM%20Cortex-M%20FLEXCAN%20FreeRTOS%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2177512%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EPlease%20check%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FiMX8QM-FLEXCAN-enable-and-test-case-on-A-core%2Fta-p%2F1349003%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FiMX8QM-FLEXCAN-enable-and-test-case-on-A-core%2Fta-p%2F1349003%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors%2FHow-to-read-from-CAN-through-M4%2Fm-p%2F1695836%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors%2FHow-to-read-from-CAN-through-M4%2Fm-p%2F1695836%3C%2FA%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E