aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stm32h7/system_stm32h7xx.c
diff options
context:
space:
mode:
authorbigtreetech <tech@biqu3d.com>2022-11-23 11:16:43 +0800
committerKevin O'Connor <kevin@koconnor.net>2022-12-02 13:26:02 -0500
commit50b2e2e67e299d71749508d2aeb45abde4b761ca (patch)
tree9fa66c3c8931b6e6a41abd5e309c291714eba18f /lib/stm32h7/system_stm32h7xx.c
parentc5d56f4438de4fd9b9a06948415eb5c8f3ecdbd7 (diff)
downloadkutter-50b2e2e67e299d71749508d2aeb45abde4b761ca.tar.gz
kutter-50b2e2e67e299d71749508d2aeb45abde4b761ca.tar.xz
kutter-50b2e2e67e299d71749508d2aeb45abde4b761ca.zip
lib: update lib/stm32h7 to v1.9.0 for stm32h723
Signed-off-by: Chen.BJ from BigTreeTech chenbj@biqu3d.com
Diffstat (limited to 'lib/stm32h7/system_stm32h7xx.c')
-rw-r--r--lib/stm32h7/system_stm32h7xx.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/lib/stm32h7/system_stm32h7xx.c b/lib/stm32h7/system_stm32h7xx.c
index 641b6069..a2286e25 100644
--- a/lib/stm32h7/system_stm32h7xx.c
+++ b/lib/stm32h7/system_stm32h7xx.c
@@ -148,14 +148,29 @@ void SystemInit (void)
SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */
#endif
/* Reset the RCC clock configuration to the default reset state ------------*/
+
+ /* Increasing the CPU frequency */
+ if(FLASH_LATENCY_DEFAULT > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
+ {
+ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
+ MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
+ }
+
/* Set HSION bit */
RCC->CR |= RCC_CR_HSION;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
- /* Reset HSEON, CSSON , CSION,RC48ON, CSIKERON PLL1ON, PLL2ON and PLL3ON bits */
+ /* Reset HSEON, HSECSSON, CSION, HSI48ON, CSIKERON, PLL1ON, PLL2ON and PLL3ON bits */
RCC->CR &= 0xEAF6ED7FU;
+
+ /* Decreasing the number of wait states because of lower CPU frequency */
+ if(FLASH_LATENCY_DEFAULT < (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
+ {
+ /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
+ MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
+ }
#if defined(D3_SRAM_BASE)
/* Reset D1CFGR register */
@@ -177,23 +192,23 @@ void SystemInit (void)
RCC->SRDCFGR = 0x00000000;
#endif
/* Reset PLLCKSELR register */
- RCC->PLLCKSELR = 0x00000000;
+ RCC->PLLCKSELR = 0x02020200;
/* Reset PLLCFGR register */
- RCC->PLLCFGR = 0x00000000;
+ RCC->PLLCFGR = 0x01FF0000;
/* Reset PLL1DIVR register */
- RCC->PLL1DIVR = 0x00000000;
+ RCC->PLL1DIVR = 0x01010280;
/* Reset PLL1FRACR register */
RCC->PLL1FRACR = 0x00000000;
/* Reset PLL2DIVR register */
- RCC->PLL2DIVR = 0x00000000;
+ RCC->PLL2DIVR = 0x01010280;
/* Reset PLL2FRACR register */
RCC->PLL2FRACR = 0x00000000;
/* Reset PLL3DIVR register */
- RCC->PLL3DIVR = 0x00000000;
+ RCC->PLL3DIVR = 0x01010280;
/* Reset PLL3FRACR register */
RCC->PLL3FRACR = 0x00000000;
@@ -231,13 +246,20 @@ void SystemInit (void)
#if defined(DUAL_CORE) && defined(CORE_CM4)
/* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
#ifdef VECT_TAB_SRAM
- SCB->VTOR = D2_AHBSRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+ SCB->VTOR = D2_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BANK2_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif /* VECT_TAB_SRAM */
#else
+ /*
+ * Disable the FMC bank1 (enabled after reset).
+ * This, prevents CPU speculation access on this bank which blocks the use of FMC during
+ * 24us. During this time the others FMC master (such as LTDC) cannot use it!
+ */
+ FMC_Bank1_R->BTCR[0] = 0x000030D2;
+
/* Configure the Vector Table location add offset address for cortex-M7 ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal AXI-RAM */
@@ -339,7 +361,8 @@ void SystemCoreClockUpdate (void)
break;
default:
- pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
+ hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
+ pllvco = ((float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
break;
}
pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
@@ -352,7 +375,7 @@ void SystemCoreClockUpdate (void)
break;
default:
- common_system_clock = CSI_VALUE;
+ common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
break;
}