Skip to main content
Amaresh
Associate III
March 1, 2022
Question

Im new to CubeIDE. When Setting up RCC (Low speed clock) to crystal resonator and adding clock and calendar in RTC, it says the HAL_RTC_Init is not defined.. how can I fix this?

  • March 1, 2022
  • 12 replies
  • 5893 views

0693W00000KauhSQAR.png

This topic has been closed for replies.

12 replies

TDK
March 1, 2022

It means that the HAL RTC files haven't been included. Open up the *_hal_conf.h file and RTC module is enabled with the line:

#define HAL_RTC_MODULE_ENABLED

"If you feel a post has answered your question, please click ""Accept as Solution""."
Amaresh
AmareshAuthor
Associate III
March 2, 2022

@TDK​ 

As in, put this line in main? If so it still shows the same error.

Amaresh
AmareshAuthor
Associate III
March 2, 2022

@TDK​ if u mean to enable it looks like it is already enabled

0693W00000Kb4HtQAJ.png

TDK
March 2, 2022

No, in *_hal_conf.h. The line should already be in there, ensure it's not commented.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Amaresh
AmareshAuthor
Associate III
March 2, 2022

Yes the above picture in inside hal_conf.h as you can see the second last define shows it has been enabled by default.

TDK
March 2, 2022

Include your IOC file if you can, or project code.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Amaresh
AmareshAuthor
Associate III
March 2, 2022
TDK
March 2, 2022

I'm not sure, looks like it should be working. Can you post the exact error message(s) you're getting?

"If you feel a post has answered your question, please click ""Accept as Solution""."
Amaresh
AmareshAuthor
Associate III
March 2, 2022

0693W00000KbAaSQAV.png

TDK
March 2, 2022
The Console tab has the exact error message. The Problems tab is the IDE’s “helpful�? way of reordering things, which is less than helpful.
The full output from the console tab would show the actual issue. Solving it is another thing. Looks like the RTC file isnt being compiled.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Amaresh
AmareshAuthor
Associate III
March 2, 2022

BTW this ioc is setup by touch gfx. When I open an ide project directly and do the same thing it doesn't give the error.

Amaresh
AmareshAuthor
Associate III
March 3, 2022
make -j8 all 
arm-none-eabi-g++ -o "STM32F469I-DISCO.elf" @"objects.list" -l:libtouchgfx-float-abi-hard.a -mcpu=cortex-m4 -T"C:\TouchGFXProjects\TestTimeandDate_3\STM32CubeIDE\STM32F469NIHX_FLASH.ld" --specs=nosys.specs -Wl,-Map="STM32F469I-DISCO.map" -Wl,--gc-sections -static -LC:/git/STM32F469-dk/stm32f469i_disco/STM32F469I-DISCO/Middlewares/ST/touchgfx/lib/core/cortex_m4f/gcc -LC:/git/stm32f469i_disco/STM32F469I-DISCO/Middlewares/ST/touchgfx/lib/core/cortex_m4f/gcc -LC:/TouchGFXProjects/TestTimeandDate_3/Middlewares/ST/touchgfx/lib/core/cortex_m4f/gcc --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Application/User/main.o: in function `MX_RTC_Init':
C:/TouchGFXProjects/TestTimeandDate_3/Core/Src/main.c:623: undefined reference to `HAL_RTC_Init'
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: C:/TouchGFXProjects/TestTimeandDate_3/Core/Src/main.c:639: undefined reference to `HAL_RTC_SetTime'
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: C:/TouchGFXProjects/TestTimeandDate_3/Core/Src/main.c:648: undefined reference to `HAL_RTC_SetDate'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:88: STM32F469I-DISCO.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
 
10:04:18 Build Failed. 5 errors, 0 warnings. (took 1s.898ms)
 

Here is the console error message

Yes I think the RTC isn't being compiled for some reason when the project is opened through touchgfx