2024-03-25 07:29 AM - last edited on 2024-03-25 08:43 AM by SofLit
@SofLit hello again,
So , i am facing a problem to display the frame i am supposed to send from CAN_Tx pin in loopback mode. I am using picoscope to display.
Here is the function i wrote to configure the Header, and send the data:
void CAN_send(void)
{
char msg[50];
CAN_TxHeaderTypeDef TxHeader;
uint32_t TxMailbox;
uint8_t TxData[4] = {'T','E','S','T'};
TxHeader.DLC = 4; // 4 data byte
TxHeader.ExtId = 0; // Not used so far
TxHeader.IDE = CAN_ID_STD; // Standard ID
TxHeader.RTR = CAN_RTR_DATA; // Data and not remote frame
TxHeader.StdId = 0x103; // Data ID
TxHeader.TransmitGlobalTime = DISABLE;
if(HAL_CAN_AddTxMessage(&hcan1, &TxHeader, TxData, &TxMailbox)!=HAL_OK)
{
Error_Handler();
}
while( HAL_CAN_IsTxMessagePending(&hcan1, TxMailbox));
sprintf(msg, "Message transmitted\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
}
In the Main function, i am calling it after the HAL_CAN_Start function. The uart connexion tells me that the frame is sent but i can't see it though.
Thank you again for your precious help!
Solved! Go to Solution.
2024-03-25 07:40 AM
Thank you for the shared main file:
I noticed two issues:
In the timing configuration:
hcan1.Init.TimeSeg1 = CAN_BS1_1TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_8TQ;
And with the filter configuration:
canfilterconfig.FilterBank = 10;
canfilterconfig.SlaveStartFilterBank = 0;
So try these configurations:
hcan1.Init.TimeSeg1 = CAN_BS1_7TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
and
canfilterconfig.FilterBank = 0;
canfilterconfig.SlaveStartFilterBank = 14;
2024-03-25 07:40 AM
Thank you for the shared main file:
I noticed two issues:
In the timing configuration:
hcan1.Init.TimeSeg1 = CAN_BS1_1TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_8TQ;
And with the filter configuration:
canfilterconfig.FilterBank = 10;
canfilterconfig.SlaveStartFilterBank = 0;
So try these configurations:
hcan1.Init.TimeSeg1 = CAN_BS1_7TQ;
hcan1.Init.TimeSeg2 = CAN_BS2_2TQ;
and
canfilterconfig.FilterBank = 0;
canfilterconfig.SlaveStartFilterBank = 14;
2024-03-25 07:46 AM
Nothing changed:
Let me inform you than i got it to work once but several weeks ago and when i added some structures and other functions in order to fit it into a real project then it couldn't work anymore. And the parameters you asked me to change were the same unfortunately.
2024-03-25 07:57 AM
Wait Wait! It works actually.
The debug mode does not allow us to see a frame. Only run mode. Thank you for your help!
Have a nice day!
2024-03-25 08:01 AM
Ok.
Could you please share your project so I could test it on one board when I have one on hands? I will do it next Wednesday.
If you couldn't share it on public send it to me by message.
2024-03-25 08:23 AM
2024-03-25 08:34 AM - edited 2024-03-26 12:37 AM
@Erwan03 wrote:
Wait Wait! It works actually.
The debug mode does not allow us to see a frame. Only run mode. Thank you for your help!
Have a nice day!
Nice! You're welcome :smiling_face_with_smiling_eyes: .. But still strange it could not be running in debug mode!
Which Toolchain are you using? I will try it with a NUCLEO-F446RE board when I have one on hands.