Skip to content

Commit 3af9379

Browse files
committed
system(wba): update STM32WBAxx system
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent ce646e6 commit 3af9379

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

system/STM32WBAxx/system_stm32wbaxx.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ void SystemInit(void)
179179
{
180180
#if defined(STM32WBAXX_SI_CUT1_0)
181181
__IO uint32_t timeout_cpu_cycles;
182+
#endif
183+
#if defined(STM32WBAXX_SI_CUT1_0) || defined (VREFBUF)
182184
__IO uint32_t tmpreg;
183185
#endif
184186

@@ -244,6 +246,25 @@ void SystemInit(void)
244246
/* Disable ADC kernel clock */
245247
CLEAR_BIT(RCC->AHB4ENR, RCC_AHB4ENR_ADC4EN);
246248
#endif
249+
250+
#if defined (VREFBUF)
251+
/* Work-around for VREFBUF peripheral issue.
252+
Refer to STM32WBA errata sheet item "VREF BUFF cannot be trimmed by EngiBit".
253+
Actions: Our SW copies the TRIM V11 (R1) in VREFBUF CCR (to guarantee the correct start
254+
trim instead the current bad value 111111).
255+
*/
256+
/* Enable VREFBUF kernel clock */
257+
SET_BIT(RCC->APB7ENR, RCC_APB7ENR_VREFEN);
258+
/* Delay after an RCC peripheral clock enabling */
259+
tmpreg = READ_BIT(RCC->APB7ENR, RCC_APB7ENR_VREFEN);
260+
(void)tmpreg;
261+
262+
/* Set TRIM V11 (R1) value */
263+
MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, ((*(uint32_t *)(FLASH_ENGY_BASE + 0x2ABUL)) & 0x3FUL));
264+
265+
/* Disable VREFBUF kernel clock */
266+
CLEAR_BIT(RCC->APB7ENR, RCC_APB7ENR_VREFEN);
267+
#endif /* VREFBUF */
247268
}
248269

249270
/**

0 commit comments

Comments
 (0)