Skip to main content
MTacc
Associate
May 18, 2023
Question

CAN-bus error-frame management on SMTF32F1x or SMTF32F4x

  • May 18, 2023
  • 4 replies
  • 1684 views

Using SMTF32F1x or SMTF32F4x or another, is it possible to receive/identify a generic error-frame on CAN-bus?

I'm using call back receiving and if I transmit an error-frame (I'm using Vector Canalyzer as tool), my call back is not running.

I also tried to enable HAL_CAN_ErrorCallback, but also this is never called.

What I have to do ?

This topic has been closed for replies.

4 replies

mƎALLEm
Technical Moderator
May 18, 2023

Hello,

What do you mean by "tried to enable HAL_CAN_ErrorCallback", did you activate error interrupt using HAL_CAN_ActivateNotification()? what is the interrupt error you did activate?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
MTacc
MTaccAuthor
Associate
May 18, 2023

Yes, the receiving of a normal frame is good, no problem.

When I transmit error frame using an external tool the call back is not called.

I writed:

 HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_ERROR_WARNING | CAN_IT_ERROR_PASSIVE | CAN_IT_BUSOFF | CAN_IT_LAST_ERROR_CODE | CAN_IT_ERROR);// Initialize CAN Bus Rx Interrupt

and also tried:

 HAL_CAN_ActivateNotification(&hcan,0xFFFFFFFF);// Initialize CAN Bus Rx Interrupt

I also activated:

#define USE_HAL_CAN_REGISTER_CALLBACKS     1U /* */

mƎALLEm
Technical Moderator
May 18, 2023

Strange. Are you sure there was error frame asserted on the bus?

Knowing that STM32 has passed CAN conformance test. See this document:

https://www.st.com/resource/en/certification_document/stm32_authentication_can.pdf

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
MTacc
MTaccAuthor
Associate
May 18, 2023

OK, I solved.

no need to set

#define USE_HAL_CAN_REGISTER_CALLBACKS     1U /* */

it is necessary to activate, inside CUBEMX, "CAN SCE interrupt" enabled.

After this error-frames are notified by

void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)