2025-12-06 2:22 AM
Hi everyone,
This is a follow-up to my previous question about LED behavior on the STM32H755ZI-Q when using OpenAMP communication between CM4 and CM7.
While debugging why LED3 on PB14 was not turning on (assigned to CM7), I found a very unusual issue in the CM7 startup code generated by STM32CubeMX.
CubeMX generates the following D2 domain clock readiness loop:
timeout = 0xFFFF;
while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));If I rewrite the loop explicitly:
while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET))
{
timeout--;
if (timeout < 0)
{
Error_Handler();
}
}then PB14 suddenly starts working normally.
If I add any variable initialization before the loop, for example:
timeout = 0xFFFF;
while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET))
{
timeout--;
if (timeout < 0)
{
Error_Handler();
}
}then PB14 stops working again — even though the rest of the code runs correctly, OpenAMP communication works, and the other LEDs behave normally.
This issue affects only PB14.
PE1 (LED2) works under all conditions
PB0 (LED1) works under all conditions
Any LED assigned to CM4 works under all conditions
But PB14 (LED3) fails only when this startup loop uses a variable or the original CubeMX line
Manual toggling also fails:
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);This outputs nothing on PB14, while PE1 and PB0 toggle correctly.
If I assign PB14 to CM4 instead of CM7, everything works fine regardless of code version.
The problem appears only when PB14 is used from CM7 during early startup.
The behavior seems influenced by timing, stack use, compiler ordering, or D2 domain clock readiness.
Even though moving PB14 to CM4 solves the issue, I still want to understand the root cause:
I will attach the same project as in my previous post for reference.
Any insights would be greatly appreciated — this behavior is extremely odd, especially since all other GPIOs work except PB14.
Thanks in advance!