cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Interrupt not firing on STM32F072

NPol
Associate

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
T J
Lead

did you enable the Fifos Rx interrupt ??

	
    __HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP1);
    __HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP0);

NPol
Associate

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!