Skip to main content
NPol
Associate
August 13, 2018
Solved

CAN Interrupt not firing on STM32F072

  • August 13, 2018
  • 3 replies
  • 1852 views

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?

This topic has been closed for replies.
Best answer by Tesla DeLorean

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

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 13, 2018

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
T J
Senior III
August 14, 2018

did you enable the Fifos Rx interrupt ??

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

NPol
NPolAuthor
Associate
August 14, 2018

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!