cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect MCU at run time?

bobdeschambault9
Associate II
Posted on March 10, 2015 at 14:57

Hi,

Is there a way to determine which MCU is being used on a board?  We are developing software for an STM32F4 and some of our tools are using the 407 and others are using a 429.  I would like to know when our code is running on a given MCU.

Thanks,

Bob
8 REPLIES 8
Posted on March 10, 2015 at 15:39

There's DBGMCU_IDCODE and you can read the flash size from it's location in the System ROM

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bobdeschambault9
Associate II
Posted on March 10, 2015 at 18:25

I notice that the values are the same in the header for both chips.  Is this like some sort of address that contains the chip part number if I read it correctly?

Posted on March 10, 2015 at 19:15

printf(''IDCODE:%08X FLASH:%04X\n'', *((uint32_t *)0xE0042000), *((uint16_t *)0x1FFF7A22));

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock
Associate III
Posted on March 10, 2015 at 21:08

Two places for CPU info.  Look at the SCB->CPUID register for general Cortex processor info.  This will tell you if it's an M0, M3 or M4 (and presumably M7).

ST has two library routines: DBGMCU_getDevID() and DBGMCU_GetRevID() for ST specific models.  Those help with errata that are rev specific.

  Jack Peacock
bobdeschambault9
Associate II
Posted on March 10, 2015 at 21:39

Thanks for the information.  I am using ST Cube v1.4 and I looked up the call, it now called ''HAL_GetDEVID()'' and returns a 32 bit unsigned integer.  There is also ''HAL_GetREVID()'' call as well.  The functions are found in stm32f4xx_hal.c.

Posted on March 10, 2015 at 23:56

> I notice that the values are the same in the header for both chips. 

What header?

What values?

JW

bobdeschambault9
Associate II
Posted on March 11, 2015 at 03:31

The header files:

stm32f407xx.h

stm32f429xx.h

The values:

#define  DBGMCU_IDCODE_DEV_ID                ((uint32_t)0x00000FFF)

#define  DBGMCU_IDCODE_REV_ID                ((uint32_t)0xFFFF0000)

Posted on March 11, 2015 at 09:17

The values:

#define  DBGMCU_IDCODE_DEV_ID                ((uint32_t)0x00000FFF)

#define  DBGMCU_IDCODE_REV_ID                ((uint32_t)0xFFFF0000)

Ah, I see. These are only masks, indicating the dev ID and rev ID fields in the 32-bit

DBGMCU_IDCODE

register.

Have you already read the content of DBGMCU_IDCODE? Does it match the values from RM0090?

JW