Reading STM32F4 unique device ID from MBED compiler

When working with the STM32 family of microcontrollers, it can be useful to evaluate the factory-programmed 96-bit UUID. The electronic signature is stored in the Flash memory area. It can be read using the JTAG/SWD or the CPU. It contains factory-programmed identification data that allow the user firmware or other external devices to automatically match its interface to the characteristics of the STM32F4xx microcontrollers.

The unique device identifier is ideally suited:
* for use as serial numbers (for example USB string serial numbers or other end applications)
* for use as security keys in order to increase the security of code in Flash memory while using and combining this unique ID with software cryptographic primitives and protocols before programming the internal Flash memory
* to activate secure boot processes, etc.

The 96-bit unique device identifier provides a reference number which is unique for any device and in any context. These bits can never be altered by the user.
The 96-bit unique device identifier can also be read in single bytes/half-words/words in different ways and then be concatenated using a custom algorithm.
According to the STM32F4 reference manual, the UUID is stored in memory at address 0x1FFF7A10.

Examples:

1. STM32-UID.h

2. Usage

References: techoverflow 1, techoverflow 2, alternative link for STM32F4 reference manual

SPI Modes

SPI knows 4 "standard" modes, reflecting the SCK's polarity (CPOL) and the SCK's phase (CPHA).

SPI Mode CPOL CPHA
0 (or 0,0) 0 0
1 (or 0,1) 0 1
2 (or 1,0) 1 0
3 (or 1,1) 1 1

The meaning is:

CPOL:
  • 0 = Clock Idle low level
  • 1 = Clock Idle high level
CPHA:
  • 0 = SDO transmit edge (*) active to idle
  • 1 = SDO transmit edge idle to active
(*): the transmit edge is the clock edge at which the SDO level changes.

In a timing diagram this looks like(only one clock pulse shown here):


The Transmit edge is the clock edge at which the SPI output data changes,
The Sampling edge is the clock edge at which the sampling of the SPI input data takes place.
The sampling edge is normally the opposite one of the transmit edge.


References: www.rosseeld.be, dlnware.com

Suppress any warning in mbed Compiler

The mbed Compiler is a very usefull development platform for microcontrollers, but sometimes you will get warning messages, some of which you know about and want to be ignored. They appear on the first lines of "Compiler output" and you need to scroll down to reach the "real" compiler errors.

You can suppress specific compiler errors and warnings by using #pragma diag_suppress in the header of your project before any include happens.

#pragma diag_suppress sets a specific warning code or multiple warning codes and the compiler will ignore those warnings.

All the error and warning codes can be found on http://infocenter.arm.com website.

Examples:



alternative link

References: developer.mbed.org/forum/, about diag_suppress tag, ARM compiler warning and error codes,