Kim GiJeong
/
cocoa_STM_ver_BIPOLAR
cocoa_STM_ver_BIPOLAR
Diff: INIT_HW/INIT_HW.cpp
- Revision:
- 1:be9b2f6d39c2
- Parent:
- 0:51c43836c1d7
--- a/INIT_HW/INIT_HW.cpp Wed Aug 14 08:13:36 2019 +0000 +++ b/INIT_HW/INIT_HW.cpp Tue Aug 20 12:35:26 2019 +0000 @@ -31,26 +31,31 @@ void Init_PWM(){ - RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // enable TIM4 clock - FastPWM pwm_v(PIN_V); - FastPWM pwm_w(PIN_W); + RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable TIM1 clock + + FastPWM pwm_a(PIN_V); // 단순히 핀 설정용 + FastPWM pwm_b(PIN_W); //ISR Setup - NVIC_EnableIRQ(TIM4_IRQn); //Enable TIM4 IRQ + NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); //Enable TIM1 IRQ - TIM4->DIER |= TIM_DIER_UIE; // enable update interrupt - TIM4->CR1 = 0x40; // CMS = 10, interrupt only when counting up // Center-aligned mode - TIM4->CR1 |= TIM_CR1_UDIS; - TIM4->CR1 |= TIM_CR1_ARPE; // autoreload on, - TIM4->RCR |= 0x001; // update event once per up/down count of TIM4 - TIM4->EGR |= TIM_EGR_UG; + TIM1->DIER |= TIM_DIER_UIE; // enable update interrupt + TIM1->CR1 = 0x40; // CMS = 10, interrupt only when counting up // Center-aligned mode + TIM1->CR1 |= TIM_CR1_UDIS; + TIM1->CR1 |= TIM_CR1_ARPE; // autoreload on, + TIM1->RCR |= 0x001; // update event once per up/down count of tim1 + TIM1->EGR |= TIM_EGR_UG; + + //PWM Setup - TIM4->PSC = 0x0; // no prescaler, timer counts up in sync with the peripheral clock - TIM4->ARR = PWM_ARR; // set auto reload, 40 khz - TIM4->CCER |= ~(TIM_CCER_CC1NP); // Interupt when low side is on. - TIM4->CR1 |= TIM_CR1_CEN; // enable TIM4 + TIM1->PSC = 0x0; // no prescaler, timer counts up in sync with the peripheral clock + TIM1->ARR = PWM_ARR; // set auto reload, 40 khz +// TIM1->CCER |= ~(TIM_CCER_CC1NP); // Interupt when low side is on. + TIM1->CR1 |= TIM_CR1_CEN; // enable TIM1 -} + // for complementary + TIM1->CCER|=0b1111; + } \ No newline at end of file