2018-02-13 11:13 AM
Hi,
I have a very strange error while migrating from Standard Peripheral Libraries to HAL libraries.
what I did was:
1. I created new Keil project for STM32F407 Discovery.
2. Added Device startup file (And CMSIS dependency)
Now in Keil Project, when I include File STM32F4xx.h from standard peripheral library (
https://github.com/pichenettes/stmlib/blob/master/third_party/STM/CMSIS/CM3_f4xx/stm32f4xx.h
) and compile the code without defining target in Keil pre-processor (STM32F40_41xxx),
I get the missing target error at line 112 (
) which is obvious.But Now if I include the same file (name wise) from HAL libraries (
) and doesn't define target preprocessor, I don't get any error.. at line 193()??? It EVEN includes the relevant header file at Line-150. i.e.♯
elif
defined(STM32F407xx)
♯
include
''
stm32f407xx.h''
which means the preprocessor
STM32F407xx
is already defined some where OR the file from HAL is defining it somewhere. I tried to dig out but couldn't find its definition in whole project or include/sub-included file..!!!!
So How is it possible that for one file (StdperiphLib) the preprocessor
STM32F407xx
is defined and for other its not??Kindly help.
Attachments:
GPIO-Blinky... Both the header files are inside project folder in different folders. Give path to which is needs to be included at a time.
Note: i am not using CubeMX.
#standard-peripheral-libraries #keil-mdk5 #stm32f4-d #hal-library2018-02-13 11:17 AM
How is it possible that for one file (StdperiphLib) the preprocessor
STM32F407xxis defined and for other its not??
Because the StdPeriph requires that you define it in the Project defines, but HAL doesn't.
IF you want to see what's actually happening, look at the Preprocessor output.
2018-02-13 12:31 PM
Thanks for the reply.
But where is the symbol visible to HAL Libraries??? From where HAL get it??
The pre-processor output I guess would not mention where STM32F407xx
is defined rather it will only include STM32F407xx.h
file.
2018-02-13 01:57 PM
Rather than excessively complicate this, just place the correct defines in the command line and make sure the Include Paths point to the appropriate directories, and in an appropriate order, so that a current and coherent set of files are pulled in.
For STM32F4-DISCO board we typically use these defines:
USE_HAL_DRIVER,STM32F407xx,USE_STM32F4_DISCO
The CubeMX F4 trees include HAL examples, and template projects, please use and review these so you have some context about how these should be formulated.
2018-02-13 06:23 PM
Clive One wrote:
just place the correct defines in the command line and make sure the Include Paths point to the appropriate directories, and in an appropriate order, so that a current and coherent set of files are pulled in.
Agreed.
No point in trying to search for any coherence between old-school SPL approach, and brave-new HAL approach - likely, there isn't any.
2018-02-13 09:23 PM
,
,
Thanks Clive and Andrew. I am doing this out of curiosity. I am not trying to compare SPL with HAL. I just want to know how the library/file figures out the pre-processor directive. Its like digging deep into how things are linked in HAL libraries?? ,
like i asked in my question, How HAL library know which target is defined at point:
♯
elif
,
defined(STM32F407xx), , ,
, ♯
include
,
'
stm32f407xx.h'
even though we didn't mentioned anything like:
USE_HAL_DRIVER,STM32F407xx,USE_STM32F4_DISCO
it means that if i include the same file for different target, say STM32F429 how does it know that now its time in include file for F429??
Any clue Please?? ,
2018-02-13 10:11 PM
I'm not sure I'm looking to play this game.
As Andrew says, have the tool generate the Pre-processor output and review that.
I'd inspect the files using my prefered File Manager, which can grep through the files and see where specific keywords are used or defined.
My expectation if there is ♯ ifndef default option somewhere, and if it defaults to an F407 parts it is not going to later default to an F429
With the HAL the idea is that you don't have to explicitly ♯ include different peripheral files, but rather ♯ include a top level one, and the USE_HAL_DRIVER define causes an stm32f4xx_hal_conf.h to be pulled from the local project.
2018-02-14 04:38 AM
Clive One wrote:
I'm not sure I'm looking to play this game.
Likewise.
You're the one that wants to pursue this - for your 'interest' - so you'll have to do the digging.
Again, examining PP output is a key tool here.
Look at other 'diagnostic' options for the tools; eg, listing full command-line, listing all defined sysmbols, .BAT file output, output log, etc, etc,...
Compare 'known-working' configurations ...
EDITED
typo
2018-02-14 04:54 AM
Thanks.