From bffdbf158e197d98545244e198132864c0490bf8 Mon Sep 17 00:00:00 2001 From: "Elise.B" Date: Mon, 2 Nov 2020 18:00:17 +0100 Subject: [PATCH] Ajout SystemClock_Config dans Voilier --- Src/Voilier.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Src/Voilier.c b/Src/Voilier.c index 6c2473a..d6fc090 100644 --- a/Src/Voilier.c +++ b/Src/Voilier.c @@ -5,6 +5,49 @@ #include "Heure.h" #include "Transmission.h" #include "Voile.h" +#include "stm32f1xx_ll_rcc.h" // utile dans la fonction SystemClock_Config +#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config +#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config + +void SystemClock_Config(void) +{ + /* Set FLASH latency */ + LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); + + /* Enable HSE oscillator */ + // ********* Commenter la ligne ci-dessous pour MCBSTM32 ***************** + // ********* Conserver la ligne si Nucléo********************************* + // LL_RCC_HSE_EnableBypass(); + LL_RCC_HSE_Enable(); + while(LL_RCC_HSE_IsReady() != 1) + { + }; + + /* Main PLL configuration and activation */ + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9); + + LL_RCC_PLL_Enable(); + while(LL_RCC_PLL_IsReady() != 1) + { + }; + + /* Sysclk activation on the main PLL */ + LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); + while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) + { + }; + + /* Set APB1 & APB2 prescaler*/ + LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); + LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); + + /* Set systick to 1ms in using frequency set to 72MHz */ + LL_Init1msTick(72000000); // utile lorsqu'on utilise la fonction LL_mDelay + + /* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */ + LL_SetSystemCoreClock(72000000); +} /** @@ -15,10 +58,12 @@ * @retval None */ void Setup(){ + SystemClock_Config(); + ConfAntiChavirement(); ConfAllure(); ConfVoile(); ConfGouvernail(); - ConfAntiChavirement(); + }