2026-01-26 9:11 PM - last edited on 2026-01-29 12:32 AM by mƎALLEm
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.
Solved! Go to Solution.
2026-01-27 12:54 PM - edited 2026-01-27 12:57 PM
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.
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.
2026-01-27 11:33 AM
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
2026-01-27 12:32 PM
Could you please share your project?
2026-01-27 12:43 PM
2026-01-27 12:54 PM - edited 2026-01-27 12:57 PM
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.
2026-01-28 8:11 PM
@mƎALLEm after talking the board layout over it looks like we might have connected PA11 pin to a wakeup pin on another component on the board. Thanks for your help!
2026-01-29 3:54 AM
@tom21 wrote:
we might have connected PA11 pin to a wakeup pin on another component on the board. Thanks for your help!
Indeed that explains the behavior.
I need to update this article (Troubleshooting bxCAN issues in Loop back mode on STM32 MCUs) with this constraint..