Skip to main content
kzawada
Associate III
November 5, 2010
Question

PWM TIM8_CH2 PC7 Not Working (50%)

  • November 5, 2010
  • 5 replies
  • 983 views
Posted on November 05, 2010 at 21:29

PWM TIM8_CH2 PC7 Not Working (50%)

    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    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);

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    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.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    kzawada
    kzawadaAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    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:

    0690X00000604tvQAA.png

    kzawada
    kzawadaAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    Needed to add the following line to connect TIM8_CH2 to PC7:

    TIM_CtrlPWMOutputs(TIM8, ENABLE);

    sonhai26988
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 14:14

    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&currentviews=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&currentviews=33