I use Timer 1 for creating Complimentary PWM Output. I Set all registers according to the STM32F3 Reference Manual. When i debug code, The Timer Counter counts very well but the TIM1_CH1 Output doesnt output anything.(Other Channel Outputs have the same issue)
Here is my code :
void Timer1_PWMInit()
{
//----------------Setup Timer 1 for 25khz Center Aligned PWM-----------------
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // Enable Timer 1 Clock
GPIOE->AFR[1] |= 0x20; // Set Alternate Function 2 For Timer 1 CH1 Output
TIM1->CR1 = 0; // Clear CR1 Register(Turn off Timer 1)
TIM1->CNT = 0; // Clear Timer Counter
TIM1->PSC = 0; // Set Timer 1 Prescaler to 1:1
TIM1->ARR = 320; // 40 us(25 khz) PWM Period
TIM1->CCR1 = 320; // Timer 1 Channel 1 Duty Cycle(%50)
TIM1->CCR2 = 320; // Timer 1 Channel 2 Duty Cycle(%50)
TIM1->CCR3 = 320; // Timer 1 Channel 3 Duty Cycle(%50)
TIM1->CCR5 = 0; // Timer 1 Channel 5 Duty Cycle
TIM1->CCMR1 = 0x6868; // Set Channel 1 and Channel 2 Output Compare mode to PWM Mode
TIM1->CCMR2 = 0x68; // Set Channel 3 Output Compare mode to PWM Mode
TIM1->CCMR3 = 0x10048; // Set Channel 5 Output Compare Mode to Combined PWM Mode
TIM1->CCER = 0x10555; // Enable Output Compare Channels
TIM1->CR1 = 0xE0; // Set Counting Mode to Center Aligned Mode
TIM1->EGR |= 0x1; // Set UG bit for Updating Registers
TIM1->BDTR = 0xC800; // Set MOE and OOSR bits for enabling Output
TIM1->CR1 |= 0x1; // Enable Timer 1
//-------------------------------------------------------------------------
}