File tree Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Expand file tree Collapse file tree 4 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 1616
1717void _pbdrv_motor_init (void ) {
1818 // TIM3 is used for port C PWM
19- RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN ;
2019 TIM3 -> PSC = 3 ; // divide by 4 (= 3 + 1), so ticks are 12MHz
2120 TIM3 -> ARR = 10000 ; // 12MHz divided by 10k makes 1.2kHz PWM
2221 TIM3 -> BDTR |= TIM_BDTR_MOE ;
Original file line number Diff line number Diff line change 1616
1717void _pbdrv_motor_init (void ) {
1818 // TIM1 provides PWM for ports A/B
19- RCC -> APB2ENR |= RCC_APB2ENR_TIM1EN ;
2019 TIM1 -> PSC = 3 ; // divide by 4 (= 3 + 1), so ticks are 12MHz
2120 TIM1 -> ARR = 10000 ; // 12MHz divided by 10k makes 1.2kHz PWM
2221 TIM1 -> BDTR |= TIM_BDTR_MOE ;
@@ -54,7 +53,6 @@ void _pbdrv_motor_init(void) {
5453 TIM1 -> EGR |= TIM_EGR_UG ;
5554
5655 // TIM3 is used for port C/D PWM
57- RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN ;
5856 TIM3 -> PSC = 3 ; // divide by 4 (= 3 + 1), so ticks are 12MHz
5957 TIM3 -> ARR = 10000 ; // 12MHz divided by 10k makes 1.2kHz PWM
6058 TIM3 -> BDTR |= TIM_BDTR_MOE ;
Original file line number Diff line number Diff line change @@ -96,14 +96,13 @@ void SystemInit(void) {
9696 // dpgeorge: enable 8-byte stack alignment for IRQ handlers, in accord with EABI
9797 SCB -> CCR |= SCB_CCR_STKALIGN_Msk ;
9898
99- // Enable all of the shared hardware modules we are using
100-
99+ // Enable all of the hardware modules we are using
101100 RCC -> AHBENR |= RCC_AHBENR_DMAEN | RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN
102101 | RCC_AHBENR_GPIOCEN | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOFEN ;
103- RCC -> APB1ENR |= RCC_APB1ENR_SPI2EN | RCC_APB1ENR_USART3EN | RCC_APB1ENR_USART4EN ;
102+ RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN | RCC_APB1ENR_SPI2EN | RCC_APB1ENR_USART3EN
103+ | RCC_APB1ENR_USART4EN ;
104104 RCC -> APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN ;
105105
106-
107106 // Keep main power on
108107 GPIOB -> MODER = (GPIOB -> MODER & ~GPIO_MODER_MODER11_Msk ) | (1 << GPIO_MODER_MODER11_Pos );
109108 GPIOB -> BSRR = GPIO_BSRR_BS_11 ;
Original file line number Diff line number Diff line change @@ -119,12 +119,12 @@ void SystemInit(void) {
119119 // dpgeorge: enable 8-byte stack alignment for IRQ handlers, in accord with EABI
120120 SCB -> CCR |= SCB_CCR_STKALIGN_Msk ;
121121
122- // Enable all of the shared hardware modules we are using
123-
122+ // Enable all of the hardware modules we are using
124123 RCC -> AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN | RCC_AHBENR_GPIOCEN
125124 | RCC_AHBENR_GPIODEN | RCC_AHBENR_GPIOFEN ;
126- RCC -> APB1ENR |= RCC_APB1ENR_USART3EN | RCC_APB1ENR_USART4EN ;
127- RCC -> APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_TIM16EN | RCC_APB2ENR_TIM15EN ;
125+ RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN | RCC_APB1ENR_USART3EN | RCC_APB1ENR_USART4EN ;
126+ RCC -> APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_TIM1EN
127+ | RCC_APB2ENR_TIM15EN | RCC_APB2ENR_TIM16EN ;
128128
129129 // Keep BOOST alive
130130 GPIOB -> BSRR = GPIO_BSRR_BS_11 ;
You can’t perform that action at this time.
0 commit comments