When I learned to manually build a STM32HAL library project template file, I found that there were 6 errors, and the types of the 6 errors were the same, and 3 of them were solved by adding hal_rcc.h
and hal_gpio.c
files . So the other 3 errors caused by the lack of the corresponding .c
file I also thought of.
But in the STM32F1xx_HAL_Driver
folder, I did not find such iconic symbols as rcc
and GPIO
. The 3 errors are as follows:
They are HAL_NVIC_SetPriority
, HAL_NVIC_SetProtityGrouping
and HAL_SYSTICK_Config
respectively.
No .c
files like NVIC
or SYSTICK
were found in the STM32F1xx_HAL_Driver
folder.
I copied the question and didn't find a suitable answer online because I simply don't know how to describe my problem. After asking a senior, he solved the problem for me in only 5 minutes.
…\Output\Template.axf: Error: L6218E: Undefined symbol HAL_NVIC_SetPriority (referred from stm32f1xx_hal.o).
There are two key words in the question, let's look at them one by one
The meaning is: The symbol xxx.c
is not defined
The meaning is: the above xxx.c
file has been called in xxxx.o
What are .o files?
The
.o
file does not exist in the project, it is generated by the.c
file during the compilation process. So we only need to find the.c
file in the project, here the corresponding name isxxxx.c
xxxx.c
?¶Ctrl+F
pops up the search boxxxxx.c
file in the Find in Files
tabkeil
xxxx.c
file already existsxxx.c
symbols¶Got the following result:
The .c
files and .h
files where HAL_NVIC_SetPriority
appeared are:
* hal_gpio.c
* hal.c
* cortex.h
From the left task bar, we can see that hal_gpio.c
and hal.c
have been added to the project file
Look for the hal_cortex.h
file
It can be seen that in the hal_cortex.h
file, we found the declaration of the corresponding function, but the definition is missing, so we need to add the hal_cortex.c
file into the project file.
It is found that all errors are resolved, indicating that the declaration and definition of the problem HAL_SYSTICK_Config
are also done in cortex.h
and cortex.c
.
At this point, the problem is solved.
There are two reasons:
C/C++
tab, follow the steps to open, you will find that we have saved the stored path beforecortex.c
file into the project file, the purpose is to save the compilation time without putting all the hal library files into the project, but in stm32fxx_hal.c
calls all the hal library's .h
file. So when retrieving, keil
can discover and find the function and location of the search