fix dc motor switching frequency
This commit is contained in:
parent
9ccbfa5cac
commit
ea88a3601e
1 changed files with 2 additions and 4 deletions
|
@ -3,14 +3,12 @@
|
||||||
#include "stm32f1xx_ll_bus.h"
|
#include "stm32f1xx_ll_bus.h"
|
||||||
#include "stm32f1xx_ll_tim.h"
|
#include "stm32f1xx_ll_tim.h"
|
||||||
|
|
||||||
#define ARR_DC_MOTOR 50000
|
#define ARR_DC_MOTOR 100
|
||||||
void DC_MOTOR_Init(void) {
|
void DC_MOTOR_Init(void) {
|
||||||
// use TIM2 since it has pa1 at channel 2 output
|
|
||||||
// setup timer 2
|
// setup timer 2
|
||||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
||||||
LL_TIM_InitTypeDef tim_init;
|
LL_TIM_InitTypeDef tim_init;
|
||||||
// todo check switching behavior of the mosfet to determine period of switching
|
tim_init.Prescaler = 35;
|
||||||
tim_init.Prescaler = 71;
|
|
||||||
tim_init.Autoreload = ARR_DC_MOTOR - 1;
|
tim_init.Autoreload = ARR_DC_MOTOR - 1;
|
||||||
tim_init.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
|
tim_init.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
|
||||||
tim_init.CounterMode=LL_TIM_COUNTERMODE_UP;
|
tim_init.CounterMode=LL_TIM_COUNTERMODE_UP;
|
||||||
|
|
Loading…
Reference in a new issue