Hallo, ich bin zur Zeit dabei mich mit den Grundlagen des STM32F103 vertraut zu machen. Hierbei bin ich auf was gestoßen, dass ich nicht verstehe. Es geht um die Definition des Controlertyps. Genauer gehts um den Codeauszug aus dem stm32f10x.h file. Hier könnte man ja den Typ festlegen aber macht man kein #define funktioniert das kompilieren trozdem. Als muss ja irgendwo ein Typ per define festgelegt worden sein aber in welcher Datei. Ich verwende die µVision IDE von Keil, dort habe ich schon in den einstellung gesucht ob hier bereits pre defines exsitieren aber leider nichts gefunden. Gruß Volker /* Uncomment the line below according to the target STM32 device used in your application */ #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) /* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */ /* #define STM32F10X_LD_VL */ /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */ /* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */ /* #define STM32F10X_MD_VL */ /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */ /* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */ /* #define STM32F10X_HD_VL */ /*!< STM32F10X_HD_VL: STM32 High density value line devices */ /* #define STM32F10X_XL */ /*!< STM32F10X_XL: STM32 XL-density devices */ /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */ #endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. - Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes. - Low-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes. - Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes. - Medium-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes. - High-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes. - High-density value line devices are STM32F100xx microcontrollers where the Flash memory density ranges between 256 and 512 Kbytes. - XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the Flash memory density ranges between 512 and 1024 Kbytes. - Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers. */ #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)" #endif
Hallo Volker, der Devicetyp wird im µVision-Project festgelegt, also innerhalb der IDE. Im Menü: Project -> Select Device..... Gruß. Tom
Hallo Tom, ja das ist klarr aber wie bekommt der compiler preprocessor das mitgeteilt bzw. wo wird z.B. #define STM32F10X_LD generiert. Ohne dieser Information würde ja die folgende Präprozessor Anweisung zum Fehler führen. #if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL) #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)" #endif Volker
Hallo Volker, in der Projektdatei Projektname-".uvopt" taucht das Device mehrfach auf. In den Headern und c-Files habe ich, bislang, das Device nicht direkt gefunden? Habe aber nur oberflächlich gesucht.
Volker schrieb: > Hallo Tom, > ja das ist klarr aber wie bekommt der compiler preprocessor das > mitgeteilt bzw. wo wird z.B. #define STM32F10X_LD generiert. Kenne deine IDE / deinen Compiler nicht, aber bei "gcc" wird das gemacht indem man z.B.: -DSTM32F10X_LD als Parameter mitgibt. siehe https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options -D name=definition The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition will be truncated by embedded newline characters. LG Stefan
>Kenne deine IDE / deinen Compiler nicht, aber bei "gcc" wird das gemacht >indem man z.B.: -DSTM32F10X_LD als Parameter mitgibt Mittels "Makefile" sollte man noch sager!
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.