Skip to content

Commit

Permalink
fix: correct ETR pin init
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorBel committed Mar 31, 2021
1 parent 725e08f commit 4d19f3c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/bldc-sensored/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,21 @@ void tim1_init()

//initialize Tim1 PWM outputs
// pin_12 for etr current chopping
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_Init(GPIOA, &GPIO_InitStructure);

TIM1->SMCR = b15 + b4 + b5 + b6; // make ETR input active low
TIM1->CR2 = 0;
TIM1->CCR1 = 1350;
TIM1->CCR2 = 1350;
TIM1->CCR3 = 1350;
uint16_t init = 350;
TIM1->CCR1 = init;
TIM1->CCR2 = init;
TIM1->CCR3 = init;
// TIM1->CCR4 = 1100;
TIM1->ARR = BLDC_CHOPPER_PERIOD;
TIM1->CR1 = 0x0001;
Expand Down Expand Up @@ -348,9 +353,12 @@ int main(void)

phase = 0;

// // tim1 setup
// tim1 setup
tim1_init();

delay(5000000); //let power supply settle
delay(5000000); //let power supply settle
delay(5000000); //let power supply settle
motorstartinit();

while (1)
Expand Down

0 comments on commit 4d19f3c

Please sign in to comment.