cancel
Showing results for 
Search instead for 
Did you mean: 

CAN(Transmit 2 Farme clear time)

J.Park
Associate II
Posted on March 19, 2018 at 05:46

hello

first of all, sorry for my short English skills....

I am working on a project that uses STM32F207 and STM32 HAL Driver using STM32CubeMX.

I succeed in Tx and Rx.

I have a question for CAN.

Data is only 8byte in CAN Frame

If I transmit 2 Frame, I have to send each 1 Frame between 7ms(when data is 8byte).

I think 7ms is too long.... but I cannot find in referenc manual about clear Tx mailbox time.

how and where can I find about clear Tx mailbox time?

Thank you in advane.

http://prev.kr/app/ColorScripter

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

  

/*** CAN 2.0B send  2 Frame  ***/

  Send_CAN1_MSG(0x080, 0x02000C12, CAN_ID_EXT, 8, 0x00026364, 0x00340100);    

// 1Frame

  HAL_Delay(7);                                                    

// 8byte -> clear delay : 7ms

  Send_CAN1_MSG(0x080, 0x02001012, CAN_ID_EXT, 8, 0x01000000, 0x00);        

// 2Frame

  

  

  

//  Send_CAN1_MSG(0x080, 0x02000C12, CAN_ID_EXT, 2, 0xFFFF0000, 0x00);    

  

//  HAL_Delay(4);                                                            // 2byte -> clear delay : 4ms

  

//  Send_CAN1_MSG(0x080, 0x02000C12, CAN_ID_EXT, 2, 0xCCCC0000, 0x00);

  

  

//  Send_CAN1_MSG(0x080, 0x02000C12, CAN_ID_EXT, 1, 0xFF000000, 0x00);    

  

//  HAL_Delay(2);                                                            // 1byte -> clear delay : 2ms

  

//  Send_CAN1_MSG(0x080, 0x02000C12, CAN_ID_EXT, 1, 0xCC000000, 0x00);

void

 Send_CAN1_MSG(uint16_t StdId, uint32_t ExtId, uint32_t IDE, uint8_t Data_Length, uint32_t Data_High, uint32_t Data_Low)

{

  

/*** Identifier ***/

  hcan1.pTxMsg->StdId = StdId;

  hcan1.pTxMsg->ExtId = ExtId;

  

/*** Remote Transmission Request ***/

  hcan1.pTxMsg->RTR = CAN_RTR_DATA;

  

/*** IDentifier Extension bit ***/

  hcan1.pTxMsg->IDE = IDE;

  

  

/*** Data Length Code ***/

  hcan1.pTxMsg->DLC = Data_Length;

  

/*** Data[0] ~ [3] ***/

  hcan1.pTxMsg->Data[0] = (Data_High & 0xFF000000)>>24;

  hcan1.pTxMsg->Data[1] = (Data_High & 0x00FF0000)>>16;

  hcan1.pTxMsg->Data[2] = (Data_High & 0x0000FF00)>>8;

  hcan1.pTxMsg->Data[3] = (Data_High & 0x000000FF);

  

/*** Data[4] ~ [7] ***/

  hcan1.pTxMsg->Data[4] = (Data_Low & 0xFF000000)>>24;

  hcan1.pTxMsg->Data[5] = (Data_Low & 0x00FF0000)>>16;

  hcan1.pTxMsg->Data[6] = (Data_Low & 0x0000FF00)>>8;

  hcan1.pTxMsg->Data[7] = (Data_Low & 0x000000FF);

  

/*** Transmission ***/

  HAL_CAN_Transmit(&hcan1, 10);

}

#mailbox #stm32 #can
1 REPLY 1
AvaTar
Lead
Posted on March 19, 2018 at 08:56

If I transmit 2 Frame, I have to send each 1 Frame between 7ms(when data is 8byte).

I think 7ms is too long.... but I cannot find in referenc manual about clear Tx mailbox time.

how and where can I find about clear Tx mailbox time?

The CAN bus is priorized by message IDs, you can check a CAN tutorial for better understanding.

If you don't use standards that dictate IDs (like CANopen), you can try to assign similar/sequential IDs to your messages.

The actual transmission depends on the current bus state, and is not really synchnronous to your code.

Not sure what the Cube code does, but I'm pretty sure it just copies the message to the TX buffer. The actual time of transmission depends on the bus load and the message ID.

You might check if CAN FD is an option for you.

It allows up to 64 byte of data.

However, all other nodes need to fulfill certain requirements to work properly in a FD network.