This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pre-Processor Location

Hi,

I have a very silly question and very strange as well. I just created a new project for stm32f407vg in Keilv5 MDK on HAL.

Following is the simple code:

This is HAL libraries FILE

#include <stm32f4xx.h>

int main () {

return 0;
}

Now just to see which header file will be selected in included file stm32f4xx.h:

#if defined(STM32F405xx)

#include "stm32f405xx.h"

#elif defined(STM32F415xx)

#include "stm32f415xx.h"

#elif defined(STM32F407xx)

#include "stm32f407xx.h"
. .
#else

#error "Please select first the target STM32F4xx device used in your application (in
stm32f4xx.h file)"

#endif

Strangly it goes to STM32F407xx selection instead of giving the error... I just spent 2-hours just to dig out where this STM32F407xx is defined?? I didn't define it in project settings C/C++ Pre-processor.
Also tried by right clicking anD go to definition but it didn't work as well.

Kindly any suggestion where this pre-processor symbol (STM32F407xx) is defined?? and is there any way in keil to track pre-processor symbols locations?

kind Regards,

Parents
  • Hello Ijaz,

    You would run into the same issue if you defined a this on a "C/C++ Pre-processor" project setting, the IDE would not be able to go to the definition, since it was not in source code.

    I suspect you are using a MDK5 project with a device family pack (DFP) probably STM32F4xx version 2.11.0. A pack is essentially a zip file with a XML description file (called a PDSC file) that tells what is in the pack, what it offers, what it needs to work.

    The idea of the packs is to hook packs from different vendors together with APIs, so they can stack like lego bricks. That means many of the definitions are are now in the PDSC file.

    You can find "STM32F407xx" in this file:

    C:\Keil_v5\ARM\PACK\Keil\STM32F4xx_DFP\2.11.0\Keil.STM32F4xx_DFP.pdsc

    If you really wanted to know, you could read able Device families and subfamilies, device names, and device variants in the device use guide.

    www.keil.com/.../packFormat.html

    But how it should work - if on Project-> options for target -> Device tab, if you choose a pack device, such as the STM32F407VGTx, (the entry will have a green chip icon next to it) that PDSC file will consider list it in the STM32F407VG entry, which is part of the , STM32F407 subfamily. This Sub-family section also creates the preprocessor definition "STM32F407xx"

    If this is not working correctly perhaps
    - You have too old of a pack installed
    - You don't have the right part selected on the options for target -> device tab.
    - You are using the legacy device pack, rather than the Software packs.
    - You have a conflict between STM CubeMX generated code and the rest of your project

    You can read more at
    www.keil.com/.../index.html
    http://www2.keil.com/mdk5/

Reply
  • Hello Ijaz,

    You would run into the same issue if you defined a this on a "C/C++ Pre-processor" project setting, the IDE would not be able to go to the definition, since it was not in source code.

    I suspect you are using a MDK5 project with a device family pack (DFP) probably STM32F4xx version 2.11.0. A pack is essentially a zip file with a XML description file (called a PDSC file) that tells what is in the pack, what it offers, what it needs to work.

    The idea of the packs is to hook packs from different vendors together with APIs, so they can stack like lego bricks. That means many of the definitions are are now in the PDSC file.

    You can find "STM32F407xx" in this file:

    C:\Keil_v5\ARM\PACK\Keil\STM32F4xx_DFP\2.11.0\Keil.STM32F4xx_DFP.pdsc

    If you really wanted to know, you could read able Device families and subfamilies, device names, and device variants in the device use guide.

    www.keil.com/.../packFormat.html

    But how it should work - if on Project-> options for target -> Device tab, if you choose a pack device, such as the STM32F407VGTx, (the entry will have a green chip icon next to it) that PDSC file will consider list it in the STM32F407VG entry, which is part of the , STM32F407 subfamily. This Sub-family section also creates the preprocessor definition "STM32F407xx"

    If this is not working correctly perhaps
    - You have too old of a pack installed
    - You don't have the right part selected on the options for target -> device tab.
    - You are using the legacy device pack, rather than the Software packs.
    - You have a conflict between STM CubeMX generated code and the rest of your project

    You can read more at
    www.keil.com/.../index.html
    http://www2.keil.com/mdk5/

Children
No data