AnsweredAssumed Answered

STM32F429 pwm

Question asked by Daattavya Aggarwal on Aug 9, 2017
Latest reply on Aug 9, 2017 by Daattavya Aggarwal

I am using stm32f429 discovery board. When I use pwm on any timer, I am not getting correct outputs, that is my duty cycle is not matching the values in the ccr and arr registers.

void enable_gpio1()
{
RCC ->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
GPIOA ->MODER |= GPIO_MODER_MODER6_1;
GPIOA ->OTYPER &= ~(GPIO_OTYPER_OT_6);
GPIOA ->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR6_1;
GPIOA ->PUPDR &= ~(GPIO_PUPDR_PUPDR6);
GPIOA ->AFR[0] = GPIO_AF2_TIM3<<24;

}

void generate_pwm1()
{
TIM3 ->CCMR1 |= TIM_CCMR1_OC1M_2;
TIM3 ->CCMR1 |= TIM_CCMR1_OC1M_1;
TIM3 ->CCMR1 &= ~(TIM_CCMR1_OC1M_0);
TIM3 ->CCMR1 |= TIM_CCMR1_OC1PE;
TIM3 ->CR1 |= TIM_CR1_ARPE;
TIM3 ->EGR |= TIM_EGR_UG;
TIM3 ->CCER &= ~(TIM_CCER_CC1P);
TIM3 ->CCER |= TIM_CCER_CC1E;
TIM3 ->ARR = 500;
TIM3 ->CCR1 = 450;
TIM3 ->CR1 |= TIM_CR1_CEN;
}

 

Now on changing the values of ARR and CCR, the output is not matching. I am using upcounting mode.

Outcomes