2018-04-15 02: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
2019-01-29 12:45 PM
2019-01-29 01:01 PM
Thank you so much for your answers ..
I have no scope to watch bus lines.
When I debug the receive side received value before and after start the system (always) equals to 0x00000001 and some times it takes 0x00000004. But there is no error.(it reads 8 bytes rxData and all of them equals to 0)
I use mcp2551 and Two stm32f407vg if you want to check i can upload the code here (the code is stm32cube's example just can filter configurations are mine).
And also i dont want to steal your time i always feel guilty about "time" when i ask for help thank you again .
2019-01-29 01:39 PM
2019-02-14 04:47 AM
I finally borrow a oscilloscope sorry for delay
when only transmitter side on the bus no another node
by using this script
if ( ( hcan1.Instance->TSR & CAN_TSR_TME0 ) == CAN_TSR_TME0 ) // (1)
{
hcan1.Instance->sTxMailBox[ 0 ].TDTR = 8;
hcan1.Instance->sTxMailBox[ 0 ].TDLR = 0x55555555;
hcan1.Instance->sTxMailBox[ 0 ].TDHR = 0x55555555;
hcan1.Instance->sTxMailBox[ 0 ].TIR = ( ( uint32_t )0x123 << 21 | CAN_TI0R_TXRQ );
}
i get
0 001 0010 0011 0001 000 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 0101 110010101111101111111
when two node on the bus with this script
if ( ( hcan1.Instance->TSR & CAN_TSR_TME0 ) == CAN_TSR_TME0 ) // (1)
{
hcan1.Instance->sTxMailBox[ 0 ].TDTR = 8;
hcan1.Instance->sTxMailBox[ 0 ].TDLR = 0x22222222;
hcan1.Instance->sTxMailBox[ 0 ].TDHR = 0x22222222;
hcan1.Instance->sTxMailBox[ 0 ].TIR = ( ( uint32_t )0x123 << 21 | CAN_TI0R_TXRQ );
}
i get
0 001 0010 0011 0001 000 001000110011001000010111001100011 0010 0010 0010 0010 0010 0010 0010 0010 11010001100111111
thank you. Best Regards.
2019-02-14 11:18 AM
2022-08-24 07:24 AM
Hi,
Did you solve the transmit error caused by not receiving ACK? If you solved it, can you please tell me your solution, I am using the same transciever and stm card as you