2018-08-13 02:58 PM
I am using a mixed LL-HAL setup on an STM32F072 target. Although the HW transmits a CAN message using HAL_CAN_Transmit_IT(), it appears that the CAN interrupts do not execute. There seem to be two-ish parts to this problem:
(1) The Main interrupt handler in the HAL libraries seems to be HAL_CAN_IRQHandler(&hcan). Looking at the startup_stm32f072xb.s file, it seems that the IRQ is combined with the CEC handler: CEC_CAN_IRQHandler(). I have created this function, following that of the other LL libraries, in the stm32f0xx_it.c file. It calls the HAL_CAN_IRQHandler() indirectly. Unfortunately, it seems that CEC_CAN_IRQHandler() does not get called, even when the TME interrupt is enabled after boot.
(2) Since this is an LL-HAL mixed setup, I don't use the HAL NVIC functions, but rather enable interrupts though the LL functions, or specifically for CAN, through __HAL_CAN_ENABLE_IT which is direct register access.
Is there something special that must be done in addition to (1) registering CEC_CAN_IRQHandler() in stm32f0xx_it.c, and (2) enabling CAN interrupts using __HAL_CAN_ENABLE_IT?
Or better yet, are there LL libraries for CAN?
Solved! Go to Solution.
2018-08-13 03:10 PM
Doesn't __HAL_CAN_ENABLE_IT configure the peripheral end, not the NVIC end, of the connectivity.
NVIC_EnableIRQ(CEC_CAN_IRQn);
NVIC_SetPriority(CEC_CAN_IRQn,0);
2018-08-13 03:10 PM
Doesn't __HAL_CAN_ENABLE_IT configure the peripheral end, not the NVIC end, of the connectivity.
NVIC_EnableIRQ(CEC_CAN_IRQn);
NVIC_SetPriority(CEC_CAN_IRQn,0);
2018-08-14 03:59 AM
did you enable the Fifos Rx interrupt ??
__HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP1);
__HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP0);
2018-08-14 06:27 AM
Configuring the NVIC was what was missing.
Working Interrupt Config is now:
__HAL_CAN_ENABLE_IT(&hcan, CAN_IT_EWG |
CAN_IT_EPV |
CAN_IT_BOF |
CAN_IT_LEC |
CAN_IT_ERR |
CAN_IT_TME );
NVIC_EnableIRQ(CEC_CAN_IRQn);
NVIC_SetPriority(CEC_CAN_IRQn,0);
Thank you!