2025-03-26 8:45 AM - edited 2025-03-26 8:46 AM
There appears to be a discrepancy between the STM32U073 reference manual and the header file for the part. Given that STM32CubeProg seems to agree with the header file, I'm inclined to think it's an error in the reference manual.
I'm looking at programming the brownout detection bits in the STM32U073. If I look at stm32u073xx.h (STM32Cube FW_U0 v1.2), I see this:
/******************* Bits definition for FLASH_OPTR register ****************/
#define FLASH_OPTR_RDP_Pos (0U)
#define FLASH_OPTR_RDP_Msk (0xFFUL << FLASH_OPTR_RDP_Pos) /*!< 0x000000FF */
#define FLASH_OPTR_RDP FLASH_OPTR_RDP_Msk
#define FLASH_OPTR_BOR_EN_Pos (8U)
#define FLASH_OPTR_BOR_EN_Msk (0x1UL << FLASH_OPTR_BOR_EN_Pos) /*!< 0x00000100 */
#define FLASH_OPTR_BOR_EN FLASH_OPTR_BOR_EN_Msk
#define FLASH_OPTR_BORR_LEV_Pos (9U)
#define FLASH_OPTR_BORR_LEV_Msk (0x3UL << FLASH_OPTR_BORR_LEV_Pos) /*!< 0x00000600 */
#define FLASH_OPTR_BORR_LEV FLASH_OPTR_BORR_LEV_Msk
#define FLASH_OPTR_BORR_LEV_0 (0x1UL << FLASH_OPTR_BORR_LEV_Pos) /*!< 0x00000200 */
#define FLASH_OPTR_BORR_LEV_1 (0x2UL << FLASH_OPTR_BORR_LEV_Pos) /*!< 0x00000400 */
#define FLASH_OPTR_BORF_LEV_Pos (11U)
#define FLASH_OPTR_BORF_LEV_Msk (0x3UL << FLASH_OPTR_BORF_LEV_Pos) /*!< 0x00001800 */
#define FLASH_OPTR_BORF_LEV FLASH_OPTR_BORF_LEV_Msk
#define FLASH_OPTR_BORF_LEV_0 (0x1UL << FLASH_OPTR_BORF_LEV_Pos) /*!< 0x00000800 */
#define FLASH_OPTR_BORF_LEV_1 (0x2UL << FLASH_OPTR_BORF_LEV_Pos) /*!< 0x00001000 */
And if I connect a Nucleo-U083 and look at STM32CubeProg (v2.19), I see this:
However, if I look in the STM32U0 reference manual (RM0503 Rev 2), I see this:
The header file and CubeProg suggest there are two bits (four levels) of BOR detection with a separate enable bit, but the reference manual suggests there are three bits of level with no separate enable. I'm inclined to believe the header file and CubeProg.
Is this an error in the reference manual?
Dana M.
2025-03-26 9:17 AM
Actually, hold on a second... I think the reference manual AND CubeProg are both wrong, in different ways.
In stm32u0xx_hal_flash.h, I see the following:
/** @defgroup FLASH_OB_USER_Type FLASH Option Bytes User Type
* @{
*/
#define OB_USER_BOR_EN FLASH_OPTR_BOR_EN /*!< BOR reset enable */
#define OB_USER_BOR_LEV (FLASH_OPTR_BORF_LEV | FLASH_OPTR_BORR_LEV) /*!< BOR reset Level */
/** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes User BOR Level
* @{
*/
#define OB_BOR_LEVEL_FALLING_0 0x00000000U /*!< BOR falling level 1 with threshold around 2.0V */
#define OB_BOR_LEVEL_FALLING_1 FLASH_OPTR_BORF_LEV_0 /*!< BOR falling level 2 with threshold around 2.2V */
#define OB_BOR_LEVEL_FALLING_2 FLASH_OPTR_BORF_LEV_1 /*!< BOR falling level 3 with threshold around 2.5V */
#define OB_BOR_LEVEL_FALLING_3 (FLASH_OPTR_BORF_LEV_0 | FLASH_OPTR_BORF_LEV_1) /*!< BOR falling level 4 with threshold around 2.8V */
#define OB_BOR_LEVEL_RISING_0 0x00000000U /*!< BOR rising level 1 with threshold around 2.1V */
#define OB_BOR_LEVEL_RISING_1 FLASH_OPTR_BORR_LEV_0 /*!< BOR rising level 2 with threshold around 2.3V */
#define OB_BOR_LEVEL_RISING_2 FLASH_OPTR_BORR_LEV_1 /*!< BOR rising level 3 with threshold around 2.6V */
#define OB_BOR_LEVEL_RISING_3 (FLASH_OPTR_BORR_LEV_0 | FLASH_OPTR_BORR_LEV_1) /*!< BOR rising level 4 with threshold around 2.9V */
From these definitions here, I can infer that the U0 has two separate brown-out level settings, one for rising power, and one for falling power. The reference manual doesn't mention any of this, and CubeProg only shows a single brownout reset level setting (BOR_LEV).
Do both the STM32U0 reference manual and CubeProg need to be fixed?
Dana M.