2010-11-05 01:29 PM
PWM TIM8_CH2 PC7 Not Working (50%)
2011-05-17 05:14 AM
I think this for TIM4 is workable, haven't tried TIM8
/* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = i16uPeriod - 1; // 0 - (Period - 1) = Period TIM_TimeBaseStructure.TIM_Prescaler = i16uPrescalerValue; // Already -1 applied TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); /* PWM1 Mode configuration: Channel2 - 50% */ TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = i16uPeriod / 2; // 50% TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC2Init(TIM4, &TIM_OCInitStructure); TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable); TIM_OC2Init(TIM4, &TIM_OCInitStructure); TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable); TIM_ARRPreloadConfig(TIM4, ENABLE); /* TIM4 enable counter */ TIM_Cmd(TIM4, ENABLE);2011-05-17 05:14 AM
It looks like the counter and the reloading is working just great from the Keil uVision tools. However, it looks like TIM8_CH2 is not connected to the actual pin (PC7).
How could I trace if the pin (PC7) is getting connected to TIM8_CH2. I can see that if I use PC7 as standard GPIO output pin I can toggle it easily. For some reason the mapping that connects TIM8_CH2 to PC7 is missing. I don't see anything obvious, but it might seem to be something in AFIO. I have already enabled the AFIO clock. The register values are the following:2011-05-17 05:14 AM
I don't have a high density part, I'd be half temped to remap TIM3 on to PC7 and try that. TIM8 should connect right up on your part as best I can tell from here.
2011-05-17 05:14 AM
Can you help me?
The Timer 8 is not running. the TIM8_CNT not count...
[DEAD LINK /public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/ARM CortexM3 STM32/Timer 8 not working STM32103RD&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%2520CortexM3%2520STM32/AllItems.aspx¤tviews=33]https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fARM%20CortexM3%20STM32%2fTimer%208%20not%20working%20STM32103RD&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000626BE2B829C32145B9EB5739142DC17E&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FARM%2520CortexM3%2520STM32%2FAllItems%2Easpx¤tviews=332011-05-17 05:14 AM
Needed to add the following line to connect TIM8_CH2 to PC7:
TIM_CtrlPWMOutputs(TIM8, ENABLE);