cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Init() Returns HAL_ERROR due to common_system_clock Being Zero on STM32H747I-Discovery

Das
Associate II

Dear STM Support Team,

I am currently working on a project using the STM32H747I-Discovery Kit and have encountered an issue during system initialization. After integrating code from the STemWin_HelloWorld example and successfully compiling, the HAL_Init() function returns HAL_ERROR.

Upon debugging, I have found that the common_system_clock variable is being set to zero when returning from the following block of code:

 

#if defined(RCC_D1CFGR_D1CPRE)
  common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
#else
  // Other conditionals or relevant code
#endif

 

HAL_RCC_GetSysClockFreq() correctly returns a value that corresponds to 64MHz, so the issue seems to arise during the prescaler application. This leads to a situation where common_system_clock becomes zero, which should not be the case.

I have double-checked the clock configurations, prescaler settings, and the relevant RCC registers but have not found any discrepancies that could lead to this issue.

Could you please advise on what might be causing this behavior or provide any additional steps to troubleshoot this problem? I am using the latest HAL library version recommended for STM32H747I-Discovery.

Thank you in advance for your support.

13 REPLIES 13
FBL
ST Employee

Hello,

As much as I am aware, to create a new C Make Project

  1. Select: Project from CMake template
  2. Select: Executable or Static library
  3. Select MCU – to enable debug!

CMakeLists.txt, and cubeide-gcc-cmake files should be generated.

If you already have a valid CMakeList you can simply import source files:

  1. Select: Project with existing CMake sources
  2. Select: Location where to create the project (.project-file).

  3. Use default location inside workspace.
  4. Add Source directory folder containing CMakeLists.txt.
  5. Build directory to generate build artifacts.

Note: the generated project is only a template to provide the project skeleton.

For more details check this app note How to use CMake in STM32CubeIDE - Application note

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.


I'm out of offce with limited access to my emails.
Happy New Year!
Das
Associate II

@FBL ,

I could resolve the IDE related problems with my project(I believe so). Now I am able to see the values for the RCC registers while debugging. But the D1CorePrescTable value seem to be different from what I saw in the example. What could be the possible reasons for that value get changed. 

Das
Associate II

@FBL  Can you tell me what could be the possible reasons for change in D1CorePrescTable? 

 

Name : D1CorePrescTable
Details:"# \036IûhQø#0yh\003û\001ñ"
Default:0x240029e0 <D1CorePrescTable>
Decimal:603990496
Hex:0x240029e0
Binary:100100000000000010100111100000
Octal:04400024740
common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU)

 

HAL_RCC_GetSysClockFreq returns 64000000

RCC->D1CFGR = 0

RCC_D1CFGR_D1CPRE = 3840

RCC_D1CFGR_D1CPRE_Pos = 8

But the  D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9} initialised got changed due to some reason. I don't know how and why. Any suggestion to debug to understand this. 

Das
Associate II

@FBL @Tesla DeLorean,

Issue identified and fixed. Thank you for the suggestions and support. Issue was in the linker script. Accidentally I changed the .rodata assigned to RAM.