From 51923fe1930c6cbcb2b6bf39ad3898fc09024edd Mon Sep 17 00:00:00 2001 From: NightHawk32 Date: Wed, 18 Dec 2024 17:59:24 +0100 Subject: [PATCH 1/2] corrected dshot bidir timing for L431. Timer @40MHz --> 2.75e-6s*40MHz = 110 --- Mcu/l431/Src/IO.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mcu/l431/Src/IO.c b/Mcu/l431/Src/IO.c index 6e349659..bce1fd06 100644 --- a/Mcu/l431/Src/IO.c +++ b/Mcu/l431/Src/IO.c @@ -68,7 +68,7 @@ void sendDshotDma() IC_TIMER_REGISTER->CCMR1 = 0x60; IC_TIMER_REGISTER->CCER = 0x3; IC_TIMER_REGISTER->PSC = output_timer_prescaler; - IC_TIMER_REGISTER->ARR = 115; + IC_TIMER_REGISTER->ARR = 110; IC_TIMER_REGISTER->EGR |= TIM_EGR_UG; #ifdef USE_TIMER_3_CHANNEL_1 From 3e1a695808c2e97c28b894eab4745af33bd953c8 Mon Sep 17 00:00:00 2001 From: NightHawk32 Date: Wed, 18 Dec 2024 21:50:48 +0100 Subject: [PATCH 2/2] switched from MSI to HSI for L431, now having better timings and more temperature stability --- Mcu/l431/Src/peripherals.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Mcu/l431/Src/peripherals.c b/Mcu/l431/Src/peripherals.c index 8df92324..0756510b 100644 --- a/Mcu/l431/Src/peripherals.c +++ b/Mcu/l431/Src/peripherals.c @@ -71,17 +71,15 @@ void SystemClock_Config(void) #endif #else - LL_RCC_MSI_Enable(); + LL_RCC_HSI_Enable(); /* Wait till MSI is ready */ - while(LL_RCC_MSI_IsReady() != 1) + while(LL_RCC_HSI_IsReady() != 1) { } - LL_RCC_MSI_EnableRangeSelection(); - LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_6); - LL_RCC_MSI_SetCalibTrimming(0); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_MSI, LL_RCC_PLLM_DIV_1, 40, LL_RCC_PLLR_DIV_2); + LL_RCC_HSI_SetCalibTrimming(16); + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 10, LL_RCC_PLLR_DIV_2); #endif LL_RCC_PLL_EnableDomain_SYS();