Skip to main content
Denis Gottardello
Associate III
January 3, 2017
Question

How to detect STM32 mcu

  • January 3, 2017
  • 4 replies
  • 976 views
Posted on January 03, 2017 at 09:26

Can I know using a #ifdef if there is a STM32F3 or STM32F4?

My idea is to write a cross mcu source.

Regards.

    This topic has been closed for replies.

    4 replies

    Tesla DeLorean
    Guru
    January 3, 2017
    Posted on January 03, 2017 at 10:40

    DBGMCU DEVID

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    ST Technical Moderator
    January 3, 2017
    Posted on January 03, 2017 at 11:35

    Dear

    Gottardello.Deni

    ‌,

    You can get some information about MCU device and revision from DBGMCU.

    You can refer to yourreference manual for more details on how to use

    DBGMCU.

    Best Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Jeroen3
    Senior
    January 3, 2017
    Posted on January 03, 2017 at 14:35

     ,

     ,

    Those are runtime values. If you want compile time values, you should really make your own. Look at some

    https://github.com/ChibiOS/ChibiOS/blob/577d33e5301ad23a3ef46811fcb20218d81e8f0e/os/common/ext/CMSIS/include/core_cmFunc.h ♯ L51

    on github, they often require this for compilers as well.

    If you put them in the flags (eg: the makefile) they will be defined in the whole project. Like those compiler type defines.

    Tesla DeLorean
    Guru
    January 3, 2017
    Posted on January 03, 2017 at 16:44

    The inference was that pre-processor were not the goal, although it is the most practical.

    There are however significant hurdles for figuring it out on the fly, given the peripherals, clocks and buses are arranged differently you'd end up with the code for both being built.

    Within a single family (ie F4) using DEVID is an effective way to determine and dynamically set the clocks/buses in maximal configurations.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..