File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,8 @@ void SystemInit(void)
179
179
{
180
180
#if defined(STM32WBAXX_SI_CUT1_0 )
181
181
__IO uint32_t timeout_cpu_cycles ;
182
+ #endif
183
+ #if defined(STM32WBAXX_SI_CUT1_0 ) || defined (VREFBUF )
182
184
__IO uint32_t tmpreg ;
183
185
#endif
184
186
@@ -244,6 +246,25 @@ void SystemInit(void)
244
246
/* Disable ADC kernel clock */
245
247
CLEAR_BIT (RCC -> AHB4ENR , RCC_AHB4ENR_ADC4EN );
246
248
#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 */
247
268
}
248
269
249
270
/**
You can’t perform that action at this time.
0 commit comments