cancel
Showing results for 
Search instead for 
Did you mean: 

Dealing with error and overload CAN frames using HAL_CAN drivers.

Posted on March 16, 2017 at 11:04

Ithink this could be a silly question, but I would like to clarify with any doubt type. 

I'm working with HAL_CAN for the stm32L4. I'm developing a fw in a sw layer where I can configure CAN controller, filter banks, reset, send and receive, etc.. I'm configuring can data and remote frames format and I would like to know

  • if error frames and overhead frames must be also generated from user code or if it's a job for the STM32 under layers level (low level drivers)?

  • It's said, if my node has recived and error frame or if it has detected an error, the answer error frames from my node are they generated automatically, or must I do some code a part in order to generate an error frame?

  • How must my code deal with can error frames?

  • are these error frames keeping under HAL_CAN drivers? Does this layer some treatment of error/overload frames?

Thanks in advance.

#hal_can #stm32l4 #can #error-frames #overload #error-interrupts
3 REPLIES 3
Richard Lowe
Senior III
Posted on March 21, 2017 at 11:00

Error frames are generated by the hardware. Once an error has been detected then, if your error interrupts are enabled the callback will be executed:

void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)
{
 if( hcan->Instance == CAN1 )
 {
 osSemaphoreRelease(can_tx_semHandle);
 // Or do whatever you need, report, led, terminal.....
 }
}�?�?�?�?�?�?�?�?

Posted on March 22, 2017 at 15:41

Thank you Richard, this was the same way I was thinking to follow. But I also need I was understanding it correctly. 

Regards.

Posted on March 23, 2017 at 09:55

Hi, Richard;

two doubts regarding the propper way of doing it, I don't know if you or someone could suggest something useful about the following questions, I hope it can be:

  1. I was thinking about how and when to enable error and overrun interrupts.I think I should enable IT flags at first part of my code (i e at my init upper level function in user code) and keep it. But I can see how transmit_it and receive_it first enables these flags and disables them at the end of both operations (after interrupt detection), at HAL_CAN level (with hal_can macros). If I want to take control of can net errors during the rest of execution, m

    ust I enable them, once again after transmit/receive_It interruptions being detected?

     So, would be there, another moment in which I also must disable this error interruption flags? 
  2. UM mentions the 'overload flag' in 'silent mode', but it doesn't say anything more. I don't know (I don't see it) if has any register or flag bit regarding to the overload frame treatment. Must I don't care about detecting or sending overload frames?

Thanks in advance.