From 5f50e2b5d57f2e21c4b5c3ecae2b88f90b6c7b99 Mon Sep 17 00:00:00 2001
From: Carsten Thiele <software@carsten-thiele.de>
Date: Tue, 21 Mar 2023 22:53:00 +0100
Subject: [PATCH] configurable HSITRIM value in SystemInit48HSI()

---
 ch32v003fun/ch32v003fun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ch32v003fun/ch32v003fun.c b/ch32v003fun/ch32v003fun.c
index 199fba7..75c6549 100644
--- a/ch32v003fun/ch32v003fun.c
+++ b/ch32v003fun/ch32v003fun.c
@@ -808,7 +808,7 @@ void SystemInit48HSI( void )
 {
 	// Values lifted from the EVT.  There is little to no documentation on what this does.
 	RCC->CFGR0 = RCC_HPRE_DIV1 | RCC_PLLSRC_HSI_Mul2;    // PLLCLK = HSI * 2 = 48 MHz; HCLK = SYSCLK = APB1
-	RCC->CTLR  = RCC_HSION | RCC_PLLON | (3 << HSITRIM); // Use HSI, but enable PLL.
+	RCC->CTLR  = RCC_HSION | RCC_PLLON | (HSITRIM << 3); // Use HSI, but enable PLL.
 	FLASH->ACTLR = FLASH_ACTLR_LATENCY_1;                // 1 Cycle Latency
 	RCC->INTR  = 0x009F0000;                             // Clear PLL, CSSC, HSE, HSI and LSI ready flags.
 
-- 
GitLab