2020-06-29 06:04 AM
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:)
Solved! Go to Solution.
2020-06-30 03:16 AM
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
2020-06-30 03:16 AM
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
2020-06-30 03:17 AM
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