Problem Sending CAN Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-15 2:27 PM
I am following the example code found here to send and receive CAN messages:
STM32Cube_FW_F4_V1.21.0\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking\Src
I can happily receive CAN messages but when I call the following code, the CAN message is never sent.
HAL_CAN_AddTxMessage( &hcan1, &TxHeader, TxData, &TxMailbox );
while(HAL_CAN_GetTxMailboxesFreeLevel(&hcan1) != 3) {}TxHeader is configured as:
TxHeader.StdId = 0x123;
TxHeader.ExtId = 0x01; TxHeader.RTR = CAN_RTR_DATA; TxHeader.IDE = CAN_ID_STD; TxHeader.DLC = 7; TxHeader.TransmitGlobalTime = DISABLE;And TxData is filled with seven bytes of data.
HAL_CAN_GetTxMailboxesFreeLevel always returns 2 and I don't see the CAN message on the bus.
Any help or idea would be gratefully appreciated.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-04-16 4:57 AM
:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-27 3:18 PM
Hi,
I have same problem about 2 weeks i stuck in here, please can you explain how could you solve this problem?
Thank you, best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-27 4:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-28 12:19 AM
Thank you so much TJ i tried ​again in debug mode TxMailbox is always equals to 0x00000001 and the txdatas are not written in TxMailbox even if the selected mailbox(0) is empty why behave like this
Best regards.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-28 12:24 AM
WRITE_REG(hcan->Instance->sTxMailBox[transmitmailbox].TDHR,
((uint32_t)aData[7] << CAN_TDH0R_DATA7_Pos) |
((uint32_t)aData[6] << CAN_TDH0R_DATA6_Pos) |
((uint32_t)aData[5] << CAN_TDH0R_DATA5_Pos) |
((uint32_t)aData[4] << CAN_TDH0R_DATA4_Pos));
WRITE_REG(hcan->Instance->sTxMailBox[transmitmailbox].TDLR,
((uint32_t)aData[3] << CAN_TDL0R_DATA3_Pos) |
((uint32_t)aData[2] << CAN_TDL0R_DATA2_Pos) |
((uint32_t)aData[1] << CAN_TDL0R_DATA1_Pos) |
((uint32_t)aData[0] << CAN_TDL0R_DATA0_Pos));
​
​
I think there is a problem but i dont know thanks for help.
​
​
​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-28 10:18 PM
HAL is not great sometimes… but useful in initialisation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-28 11:53 PM
what values do you have for CAN_TDH0R_DATA(0..7)_Pos ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-29 12:01 AM
​thank you for your interest...
I have datas like these;
TxData[0]​=0x11;
TxData[1]​=0x12;
TxData[2]​=0x13;
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-29 12:29 PM
CAN_TDH0R_DATA7_Pos
CAN_TDH0R_DATA6_Pos
CAN_TDH0R_DATA5_Pos
CAN_TDH0R_DATA4_Pos
CAN_TDL0R_DATA3_Pos
CAN_TDL0R_DATA2_Pos
CAN_TDL0R_DATA1_Pos
CAN_TDL0R_DATA0_Pos
((uint32_t)aData[3] << CAN_TDL0R_DATA3_Pos)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-29 12:37 PM
CAN_TDH0R_DATA7_Pos=0x00000018
​
CAN_TDH0R_DATA6_Pos=0x00000010
​
CAN_TDH0R_DATA5_Pos=0x00000008
​
CAN_TDH0R_DATA4_Pos=0x00000000
​
CAN_TDL0R_DATA3_Pos=0x00000018
​
CAN_TDL0R_DATA2_Pos=0x00000010
​
CAN_TDL0R_DATA1_Pos=0x00000008
​
CAN_TDL0R_DATA0_Pos=0x00000000
