cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RBT6 TIM2 PWM notwork

mahdi zamani
Associate II
Posted on March 30, 2018 at 09:15

hi 

i write this code for TIM2 CH3 PWM generation GPIOB.10

but it not works 

can help too me ....

BEST regards 

// RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

//

// GPIO_StructInit(&port);

// port.GPIO_Mode = GPIO_Mode_AF_PP;

// port.GPIO_Pin = GPIO_Pin_10;

// port.GPIO_Speed = GPIO_Speed_10MHz;

// GPIO_Init(GPIOB, &port);

//

// TIM_TimeBaseStructInit(&timer);

// timer.TIM_Prescaler = 720;

// timer.TIM_Period = 1000;

// timer.TIM_ClockDivision = 2;

// timer.TIM_CounterMode = TIM_CounterMode_Up;

// TIM_TimeBaseInit(TIM2, &timer);

//

// TIM_OCStructInit(&timerPWM);

// timerPWM.TIM_Pulse = 15;

// timerPWM.TIM_OCMode = TIM_OCMode_PWM1;

// timerPWM.TIM_OutputState = TIM_OutputState_Enable;

// timerPWM.TIM_OCPolarity = TIM_OCPolarity_High;

// TIM_OC3Init(TIM2, &timerPWM);

//

// TIM_Cmd(TIM2, ENABLE);

#tim-pwm #stm32 #timer #pwm #timer2 #notworking #bug?
2 REPLIES 2
stm322399
Senior
Posted on March 30, 2018 at 10:30

Check what AFIO_MAPR register can do for you. Using PB10 for TIM2_CH3 is not the default configuration.

Posted on March 30, 2018 at 18:14

can edit this register with spl ? 

do you know function for it ?

can sent me sample code frome it ?