cancel
Showing results for 
Search instead for 
Did you mean: 

CAN frame monitoring problem in loopback mode

Erwan03
Associate III

@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!

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

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;
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
SofLit
ST Employee

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;
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Erwan03
Associate III

Nothing changed: 

Erwan03_0-1711377842439.png

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.

Wait Wait! It works actually.

The debug mode does not allow us to see a frame. Only run mode. Thank you for your help!

 

Erwan03_0-1711378661796.png

 

Have a nice day!

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

It seems that i cannot uplink the whlole project because not all files are supported.

Everything i wrote is in the main.c though. Then please find attached the main.c and .ioc files so you can test it


@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!

 

Erwan03_0-1711378661796.png

 

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.