![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
rainbow
Diff: INIT_HW/INIT_HW.cpp
- Revision:
- 252:3ffd78cbd029
- Parent:
- 250:91d3ec3a087e
- Child:
- 253:c53d4c26b04a
--- a/INIT_HW/INIT_HW.cpp Wed Jul 06 08:08:15 2022 +0000 +++ b/INIT_HW/INIT_HW.cpp Wed Jul 20 07:50:48 2022 +0000 @@ -179,39 +179,59 @@ void Init_TMR1() { - RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable TIM1 clock - - FastPWM pwm_H1(PIN_H1); - FastPWM pwm_L1(PIN_L1); - FastPWM pwm_H2(PIN_H2); - FastPWM pwm_L2(PIN_L2); - - + RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable TIM4 clock + FastPWM pwm_v(PIN_H1); + FastPWM pwm_w(PIN_L1); + TIM1->CR2 |= 0x20; //MMS = 010 - - TIM1->DIER |= TIM_DIER_UIE; // enable update interrupt TIM1->CR1 = 0x40; // CMS = 10, interrupt only when counting up // Center-aligned mode -// TIM1->CR1 = 0x10; // 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; - TIM1->CCMR1 |= 0x60; //CH1 - PWM mode 1 - TIM1->CCMR1 |= 0x6000; //CH2 - PWM mode 1 - TIM1->PSC = 0x0; // no prescaler, timer counts up in sync with the peripheral clock TIM1->ARR = TMR1_COUNT-1; // set auto reload, 20 khz TIM1->CNT = 0; TIM1->SR = 0; - TIM1->CCER |= 0x05; // CC1E = 1, CC1P = 0, CC1NE = 1, CC1NP = 0 - TIM1->CCER |= 0x50; // CC2E = 1, CC2P = 0, CC2NE = 1, CC2NP = 0 + TIM1->CR1 |= TIM_CR1_CEN; // enable TIM1 + + - TIM1->BDTR |= 0x8000; // MOE = 1; -// TIM1->BDTR |= 0x7F; // Dead-time - TIM1->BDTR |= 0x05; - TIM1->CR1 |= TIM_CR1_CEN; // enable TIM1 +// RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable TIM1 clock +// +// FastPWM pwm_H1(PIN_H1); +// FastPWM pwm_L1(PIN_L1); +// FastPWM pwm_H2(PIN_H2); +// FastPWM pwm_L2(PIN_L2); +// +// +// TIM1->CR2 |= 0x20; //MMS = 010 +// +// +// TIM1->DIER |= TIM_DIER_UIE; // enable update interrupt +// TIM1->CR1 = 0x40; // CMS = 10, interrupt only when counting up // Center-aligned mode +//// TIM1->CR1 = 0x10; // 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; +// +// TIM1->CCMR1 |= 0x60; //CH1 - PWM mode 1 +// TIM1->CCMR1 |= 0x6000; //CH2 - PWM mode 1 +// +// TIM1->PSC = 0x0; // no prescaler, timer counts up in sync with the peripheral clock +// TIM1->ARR = TMR1_COUNT-1; // set auto reload, 20 khz +// TIM1->CNT = 0; +// TIM1->SR = 0; +// TIM1->CCER |= 0x05; // CC1E = 1, CC1P = 0, CC1NE = 1, CC1NP = 0 +// TIM1->CCER |= 0x50; // CC2E = 1, CC2P = 0, CC2NE = 1, CC2NP = 0 +// +// TIM1->BDTR |= 0x8000; // MOE = 1; +//// TIM1->BDTR |= 0x7F; // Dead-time +// TIM1->BDTR |= 0x05; +// TIM1->CR1 |= TIM_CR1_CEN; // enable TIM1 } void Init_TIM4() @@ -228,7 +248,7 @@ TIM4->PSC = 10-1; // 10 prescaler, timer counts up in sync with the peripheral clock TIM4->ARR = 1; TIM4->CNT = 0; - TIM4->SR = 0; + TIM4->SR = 0; TIM4->SMCR = 0x07; //External clock mode TIM4->CR1 |= TIM_CR1_CEN; // enable TIM4 } \ No newline at end of file