Skip to main content
Uwe Bonnes
Chief
March 10, 2016
Question

Usage of (uint32_t) in device headers.

  • March 10, 2016
  • 6 replies
  • 1019 views
Posted on March 10, 2016 at 16:14

STM32 device headers use e.g.

#define FLASH_BASE            ((uint32_t)0x08000000U)

  /*!< FLASH(up to 1 MB) base address in the alias region  */

while e.g. Freescale uses in a similar situation

#define ADC0_BASE                                (0x4003B000u)

The usage of the (uint32_t) cast by ST denied to use FLASH_BASE in preprocessor expressions. Please consider dropping the sometimes harmfull (uint32_t) cast where not explicit needed!

    This topic has been closed for replies.

    6 replies

    Walid FTITI_O
    Visitor II
    March 11, 2016
    Posted on March 11, 2016 at 11:09

    Hi bonnes.uwe,

    Thanks for your feedback, I will report this to the team.

    -Hannibal-

    Walid FTITI_O
    Visitor II
    March 31, 2016
    Posted on March 31, 2016 at 13:20

    Hi bonnes.uwe, 

    Your feedback will be implimented in the new release. Thanks for the contribution.

    -Hannibal-

    Radosław
    Associate II
    March 31, 2016
    Posted on March 31, 2016 at 14:05

    Using macro sufix and cast to uint32 is double solution. 

    First st add cast in last revision add ''U'' for misra compilance.  This is chaotic. 

    Uwe Bonnes
    Chief
    April 13, 2016
    Posted on April 13, 2016 at 12:31

    I can confirm the confusion.

    Uwe Bonnes
    Chief
    November 30, 2016
    Posted on November 30, 2016 at 13:45

    A construct like  ((uint32_t)0x08000000U is still used in some places in the most recent Cube library update, e.g. in the L4 library in all xxx_BASE definitions and

    for F4 in the F423 AES definitions.

    AvaTar
    Senior III
    November 30, 2016
    Posted on November 30, 2016 at 13:56

    > A construct like  ((uint32_t)0x08000000U is still used in some places in the most recent Cube library update, ...

     

    I'd guess as a kowtow towards (potential) MISRA-obsessed automotive customers ...