Skip to main content
Associate
January 27, 2026
Solved

CAN Loopback on STM32L431KCU Issue

  • January 27, 2026
  • 1 reply
  • 302 views

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.

Best answer by mƎALLEm

Hello,

I didn't catch any issue in your code.

The remaining question: is there something connected on PA11 or PA12? if yes, you shoud absolutely disconnect any external hardware from these pins except if you have a CAN tranceiver on these pins.

 

1 reply

mƎALLEm
Technical Moderator
January 27, 2026

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."
tom21Author
Associate
January 27, 2026

Hi @mƎALLEm ,

I started clean and walked through the guide again step-by-step, did not have any luck it still errors out in the HAL_CAN_START() function waiting for the INAK to clear. Any other suggestions? 

Thanks

mƎALLEm
Technical Moderator
January 27, 2026

Could you please share your project?

"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."