cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Loopback on STM32L431KCU Issue

tom21
Visitor

I am trying to get the CAN Loopback up and running on my STM32L431KCU (CAN1), I have tried to follow the: Guide to CAN (bxCAN/CAN2.0) configuration in Loop back mode on STM32 MCUs. But I am getting stuck in the "HAL_CAN_Start()" function where its waiting for the acknowledgement: 

/* Wait the acknowledge */

while ((hcan->Instance->MSR & CAN_MSR_INAK) != 0U)

{

/* Check for the Timeout */

if ((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)

{

/* Update error code */

hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;

 

/* Change CAN state */

hcan->State = HAL_CAN_STATE_ERROR;

 

return HAL_ERROR;

}

}

I then created a new project following the CAN loopback project listed here to get a working project and around my issue: Solved: CAN bus doesn't work in loopback mode - STMicroelectronics Community

Using the same MX CAN config, APB1 of 80MHz, example program, and I still run into being stuck in the "HAL_CAN_Start()". I am using STM32CubeIDE 2.0.0 and MX 6.16.1, any help would be much appreciated.

1 REPLY 1
mƎALLEm
ST Employee

Hello @tom21 and welcome to the ST community,

You can refer to this knowledge base article: Guide to CAN (bxCAN/CAN2.0) configuration in Loop back mode on STM32 MCUs

If you followed that guide and didn't work I'm sure you missed something on that guide!

In next time please use </> button to paste your code.

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.