cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug report] : CubeMx CAN STM32F1 HAL_CAN_Receive_IT Problem

SURLEAU.Frederic
Associate III
Posted on October 14, 2016 at 11:19

References :

  STM32CudeMX 4.16.0

  STM32Cube_FW_F1_V1.4.0

  STM32F103CBT6

The project uses FREERTOS.

Hi All,

Once CAN is configured and filters are set, I call HAL_CAN_Receive_IT : OK

On receiving a CAN frame, HAL_CAN_RxCpltCallback is called : OK

  In HAL_CAN_RxCpltCallback, a signal is sent to a thread to handle the frame.

  The thread receiving the signal, reads the frame an then calls HAL_CAN_Receive_IT for next frames : OK

At some time, the application calls HAL_CAN_Transmit_IT to send a frame : OK

When the frame is sent, HAL_CAN_TxCpltCallback is then called :

multiple times...

It is not only called when the frame is sent, it is also called when a frame is received, because in stm32f1xx_hal_can.c, the function HAL_CAN_Receive_IT enables ''Transmit mailbox empty Interrupt'' ( CAN_IT_TME ).

I think it should not !

All CAN IRQ Handlers generated by STM32CudeMX calls the same function HAL_CAN_IRQHandler in stm32f1xx_hal_can.c.

CAN_Transmit_IT is called because CAN_IT_TME has been enabled and the status of CAN_TXMAILBOX_* haven't changed.

Removing ''CAN_IT_TME'' in HAL_CAN_Receive_IT solved the problem for me.

Best regards, Fr�d�ric.

#can-stm32f1-stm32cubemx
3 REPLIES 3
SURLEAU.Frederic
Associate III
Posted on October 25, 2016 at 11:18

Hi,

No one has an idea about this problem ?

Am I right or do I missed something ?

Regards,

Frédéric.
SURLEAU.Frederic
Associate III
Posted on October 31, 2016 at 09:48

Hi,

I looked into hal driver for STM32F4 ( Firmware 1.13.0 ).

In this firmware, the HAL_CAN_Receive_IT function does not ''Enable Transmit mailbox empty Interrupt''.

Regards,

Frédéric.
Posted on July 11, 2018 at 14:40

Hello 

Surleau.Fr_d_ric

 ,

For STM32F4, the HAL CAN driver is reworked to bypass limitations on CAN present with previous HAL CAN driver versions.

So, It is recommended to use the new HAL CAN driver, which is located as usual in Driver/STM32F4xx_HAL_Driver/Src and Driver/STM32F4xx_HAL_Driver/Inc folders. It can be enabled through switch HAL_CAN_MODULE_ENABLED in stm32f4xx_hal_conf.h file.

For STM32F1, the 

HAL CAN driver will be reworked in the coming release.

So, k

eep an eye out for the coming update.

With Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen