Skip to content

hal_conf_extra.h not correctly included when Oscillators are configured #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DanielLiebler opened this issue Nov 2, 2020 · 1 comment

Comments

@DanielLiebler
Copy link

Describe the bug

When HAL_RCC_OscConfig() is called for the initialization, the values of hal_conf_extra.h are not yet present.

This issue comes up because I am using an STM Nucleo F746ZG, powered by an external source. Because the HSE Oscillator quartz is not included in the Nucleo, it is using the ST-Link as a Clock source. But this takes longer to give a clock signal. Therefore I need to increase the HSE_STARTUP_TIMEOUT(This in itself could be changed for the Nucleo default settings, in my opinion).

To Reproduce

I wrote a hal_conf_extra.h containing:

#define HSE_STARTUP_TIMEOUT 20000 
#define TestVal

I modified HAL_RCC_OscConfig() (In file \system\Drivers\STM32F7xx_HAL_Driver\Src\stm32f7xx_hal_rcc.c) to also contain:

#ifndef TestVal
  while(1) {}
#endif

Then I connected a debugger and let it reboot.
After a bit of time, I halt the processor with the debugger to see what it is executing, and we are in this infinite loop.

Another possibility to test it would be to check HSE_TIMEOUT_VALUE which should be derived from HSE_STARTUP_TIMEOUT.
You could test this in stm32f7xx_hal_rcc.c like:

if (HSE_TIMEOUT_VALUE != 20000) {
  while(1) {}
}

And in this case, we are also stuck in the infinite loop.

But the weird thing is:

when running this and having the following code in my Arduino setup() function(having the infinite loops removed):

#ifdef TestVal
  Serial.println("TestVal is defined");
#endif

The Serial output appears on the console.

Expected behavior
The expected behavior would be for those values to be defined like assumed, so we don't enter the infinite loops.

Desktop (please complete the following information):

Board (please complete the following information):

  • Name: STM Nucleo F746ZG

Additional info

Also, if you wonder about the other clock issue, why I even want to increase the startup time: This issue only arises, when powering up from external power. When I have the USB cable attached or reboot with the reboot button, the clock is fast enough established/already established.

I couldn't find any information on how to use the hal_conf_extra.h with PlatformIO, so I could be missing something that needs to be configured for this to work with PlatformIO.

@gudnimg
Copy link
Contributor

gudnimg commented Nov 2, 2020

The HAL driver is outdated on Platform IO. Try updating it manually from 1.14.0 to 1.16.0 and see if that fixes the issue. See #439

I have no idea if that will fix this for you, its just an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants