cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect STM32 mcu

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.

4 REPLIES 4
Posted on January 03, 2017 at 10:40

DBGMCU DEVID

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee
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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
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.

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
Up vote any posts that you find helpful, it shows what's working..