2026-01-26 9:11 PM
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.
2026-01-27 12:22 AM - edited 2026-01-27 12:25 AM
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.