S32K HardFault exception

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K HardFault exception

695 Views
Contributor V

Hello,

I'm having an issue with FreeRTOS on S32K.

The issue is very similar to what is describe here: https://community.nxp.com/thread/422337

I am getting random HardFault issue in function uxListRemove.

Sometimes also "The processor has escalated a configurable-priority exception to HardFault. An instruction executed with an invalid EPSR.T or EPSR.IT field. Exception occured at: 0x0"
I'm using IAR compiler and IDE and it doesn't give me the callstack when the HardFault issue occurs.

My Freertos configuration is the same as in S32K SDK example:

#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x0F
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 0x05


#define configKERNEL_INTERRUPT_PRIORITY (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8-configPRIO_BITS))
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8-configPRIO_BITS))

My project uses UART interrupts, CAN interrupts and FreeRTOS xTimer along with 4 tasks and the IDLE task.

CAN bus (500kbps) is receiving 8 frames every 100ms and sending 1 frame every 100ms

UART is sending 13Bytes every 100ms (921kbps)

I'm using a 10ms timer to poll the UART reception. When this timer is disabled, the HardFault issue doesn't occur.

I tried to changed the FreeRTOS default timer configuration but it doesn't give any good result.

Do you have any advice on how to find the root cause of this issue?

Thank you.

0 Kudos
4 Replies

71 Views
Contributor V

Hello,

I believed I found the issue but not 100% sure.

Initially I though it was related to my timer but I enabled configASSERT option in FreeRTOS to check the interrupt configuration and found that my CAN interrupt had a priority set to 0.

In the CAN interrupt I'm setting FreeRTOS Event (which was configured with configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY=1). So the first CAN INT received was triggering configASSERT.

After setting the CAN priority to 1, I'm not able to reproduce my issue.

My UART Interrupt still as priority 0 but it doesn't use FreeRTOS call so I should be safe.

Not sure if it's the best way to fix this issue but it seems to have worked for me.

0 Kudos

71 Views
NXP Employee
NXP Employee

Hi Antoine monmarché

Sorry for the late reply. Ok, so if your last implementation works correctly, this tells us that this is the correct implementation for this. I would recommend you verifying the CAN interrupt handler that you have implemented along with FreeRTOS, does this use something related with FreeRTOS?

Regards

Jorge Alcala

0 Kudos

71 Views
Contributor V

Hello Jorge,

Yes we are calling the function OSA_EventSet which comes from fsl_os_abstraction that we ported from the KW36 SDK.

This function is calling API from FreeRTOS.

0 Kudos

71 Views
NXP Employee
NXP Employee

Hi Antoine monmarché

It is not recommendable using FreeRTOS APIs inside interrupt handler when you are working in a FreeRTOS environment, this is a good practice in order to have control between the tasks and the interrupt handlers.

Also, when you are working with an RTOS, your interruption priorities shouldn't be smaller than the system call of the scheduler because the scheduler needs to work only when the CPU doesn't have any other interruption to handle. Please change both CAN and UART interrupt priorities to be bigger than your syscall (which in your example is 1).

Best regards

Jorge Alcala

0 Kudos