cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 CAN1, CAN2 sending data simultaneously is it possible ?

Marcin Rozycki
Associate
Posted on January 06, 2018 at 13:45

I want to send data over CAN1, CAN2  at the same time,

so in the Code simple : 

      HAL_CAN_Transmit(&hcan1, 50);

      HAL_CAN_Transmit(&hcan2, 50) ;

so I'm getting situation presented on upper side of the image :

the data CAN2 are send when CAN1 finish transmission. 

Is it normal ? 

My expectation is that CAN2 will start transmission before CAN1 end transmitting data. 

Is it related that CAN1 and CAN2 are sharing   some MCU resources ? 

0690X00000609EsQAI.png

my MCU is STM32F413, speed is 10kbps, HAL  library,    

CAN1,CAN2 are connected to two  different physical  CAN BUS

regards

#bxcan #hal_can_transmit #stm32f4 #hal #slave #master
2 REPLIES 2
Jack Peacock
Associate II
Posted on January 06, 2018 at 15:56

You didn't state if CAN1 and CAN2 are on the same or different buses.  If you try to send two transmissions on the same bus at the same time the higher priority message will force the lower priority message (determined by header ID bits) to back off.  However on two separate buses yes you can overlap, and this technique is supported in some CAN protocols such as later versions of CANopen.

On a single bus if the first message is past the header the second will not start.  If it does you will get a bus error.  Messages from two transmitter must be synchronized to start at the same time in order for the priority bit checking to work.  This is the primary difference between CAN and similar interfaces such as RS-485, and is central to the whole concept of the short message ID instead of the usual packet header in other networks.

  Jack Peacock

Posted on January 06, 2018 at 16:20

yes sorry, I didn't mentioned about that.

CAN1, CAN2 are connected to the different physical CAN BUS.

My assumption was, that it should be available send data at the same time . I still cannot find explanation for that.