cancel
Showing results for 
Search instead for 
Did you mean: 

F042K6 - stuck in CAN receive interrupt

retro
Associate III

Hello,

I am trying to set up CAN communication on my F042K6 using the HAL library. I have followed the stm guide (attached). I got most of the functionality working, however if i try to use the Rx interrupt using "void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef*hcan)" the MCU gets stuck in this interrupt when it receives a message. I do not know what i am doing wrong and why I cannot leave the interrupt. I think it might have something to do with the NVIC interrupt priorities maybe? If someone could help me out it would be greatly appreciated. Please see attached my code, NVIC settings and the guide i followed.

Thank you:)

12 REPLIES 12
retro
Associate III

I found the problem, it was just me being an idiot. I wrote: HAL_CAN_GetRxMessage(&hcan,CAN_RX_FIFO0,&RxHeader,RxData); instead of HAL_CAN_GetRxMessage(hcan,CAN_RX_FIFO0,&RxHeader,RxData); so had the extra &. The GetRxMessage also clears the message from the buffer so the interrupt kept cycling as it was seeing a message in the buffer as per Cortex-M mechanics

I found the problem, it was just me being an idiot. I wrote: HAL_CAN_GetRxMessage(&hcan,CAN_RX_FIFO0,&RxHeader,RxData); instead of HAL_CAN_GetRxMessage(hcan,CAN_RX_FIFO0,&RxHeader,RxData); so had the extra &. The GetRxMessage also clears the message from the buffer so the interrupt kept cycling as it was seeing a message in the buffer as per Cortex-M mechanics

retro
Associate III

For anyone that runs into a simillar issue:

I found the problem, it was just me being an idiot. I wrote: HAL_CAN_GetRxMessage(&hcan,CAN_RX_FIFO0,&RxHeader,RxData); instead of HAL_CAN_GetRxMessage(hcan,CAN_RX_FIFO0,&RxHeader,RxData); so had the extra &. The GetRxMessage also clears the message from the buffer so the interrupt kept cycling as it was seeing a message in the buffer as per Cortex-M mechanics