From ea88a3601ea9330ceef40cda558beac453e00a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasper=20G=C3=BCldenstein?= Date: Sun, 15 Nov 2020 17:36:16 +0100 Subject: [PATCH] fix dc motor switching frequency --- keil_project/Services/DcMotor.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/keil_project/Services/DcMotor.c b/keil_project/Services/DcMotor.c index c417e61..95961ac 100644 --- a/keil_project/Services/DcMotor.c +++ b/keil_project/Services/DcMotor.c @@ -3,14 +3,12 @@ #include "stm32f1xx_ll_bus.h" #include "stm32f1xx_ll_tim.h" -#define ARR_DC_MOTOR 50000 +#define ARR_DC_MOTOR 100 void DC_MOTOR_Init(void) { - // use TIM2 since it has pa1 at channel 2 output // setup timer 2 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); LL_TIM_InitTypeDef tim_init; - // todo check switching behavior of the mosfet to determine period of switching - tim_init.Prescaler = 71; + tim_init.Prescaler = 35; tim_init.Autoreload = ARR_DC_MOTOR - 1; tim_init.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1; tim_init.CounterMode=LL_TIM_COUNTERMODE_UP;