2009-09-08 5:47 PM
pls help; pwm TIM3 from PC6 doesnt work
2011-05-17 4:17 AM
hi, i am trying to use TIM3 Channel 1 as PWM from PC6 as AF; but the brigthness doesnt change. what am i doing wrong?? pls help...
here is the code: RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM3 , ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_OCInitTypeDef TIM_OCInitStructure; //this pin functions as AF; when remapping GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE); /*GPIOC Configuration: TIM3 channel 1 */ /* make sure that C port is opened in RCC*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); TIM_Cmd(TIM3, DISABLE); TIM_ARRPreloadConfig(TIM3, ENABLE); /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = 999; TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); /* PWM1 Mode configuration: Channel1 */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_Channel = TIM_Channel_1; TIM_OCInitStructure.TIM_Pulse = 500; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInit(TIM3, &TIM_OCInitStructure); TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable); TIM_ARRPreloadConfig(TIM3, ENABLE); /* TIM3 enable counter */ TIM_Cmd(TIM3, ENABLE); TIM_SetCompare1(TIM3,0x10);2011-05-17 4:17 AM
Hi,
I am using the timers now too, but I don't use the library calls because they are too bloated for my application. I noticed that you did not enable the output pins on channel 1 (TIM3_CCER). Maybe that is your problem. Currently I got timer 3 channel 1 working in PWM mode without the remap, but it does not work when I turn on the remap, even though I set the GPIO pins to AFO push-pull for both possible destinations, and turned on the AFIO peripheral clock. Do you have ideas about this ? Thanks, Phil2011-05-17 4:17 AM
Hi,
In my case my problem was caused by not turning off the SWJ, which conflicted with PB4 in my chip. You may want to check this for your chip. PhilWe’re moving the ST Community to a new platform to give you a better and more reliable community experience.