2011-07-04 10:03 AM
void TIM3init(void) {
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = 7200; TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = 2000; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC3Init(TIM3, &TIM_OCInitStructure); TIM_OC4Init(TIM3, &TIM_OCInitStructure);TIM_CCPreloadControl(TIM3, DISABLE);
TIM_Cmd(TIM3, ENABLE);
TIM_CtrlPWMOutputs(TIM3, ENABLE); } void run_motor(void){ TIM_SelectOCxM(TIM3, TIM_Channel_3, TIM_OCMode_PWM1); TIM_CCxCmd(TIM3, TIM_Channel_3, TIM_CCx_Enable); TIM_SelectOCxM(TIM3, TIM_Channel_4, TIM_ForcedAction_Active); TIM_CCxCmd(TIM3, TIM_Channel_4, TIM_CCx_Disable); } with above code I get logic ''1'' at TIM3_CH3 instead of PWM can anybody help ?2011-07-04 11:16 PM
Hello,
I hope you have enabled tim3 and GPIOB peripheral clock? Rgds,2011-07-05 12:29 AM
yes I have enabled them ;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);2011-07-05 07:49 AM
I am sorry
I found my coding error the problem is solved thank you2011-07-08 01:33 AM