AnsweredAssumed Answered

Final State of PWM

Question asked by asl.sean on Feb 4, 2013
Latest reply on Feb 5, 2013 by asl.sean
Hi ,
I am trying to drive a LED Driver IC with a PWM signal on button press. 

However , it seems that at the end of a PWM cycle the LED final state is not determinable (maybe on/off). It seem that it is dependent of the final state of the pulse. Is is possible to ensure a low state at the end of a pwm cycle ?

I am using stm32f4 and mic4812

My code is as follows,
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM12, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
    GPIO_Init(GPIOH, &GPIO_InitStructure);
    GPIO_PinAFConfig(GPIOH, GPIO_PinSource9, GPIO_AF_TIM12);
    PrescalerValue = (uint16_t)((SystemCoreClock) / 100000) - 1;
    /* Time base configuration */
    TIM_TimeBaseStructure.TIM_Period = 49;
    TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
    TIM_TimeBaseStructure.TIM_ClockDivision = 0;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM12, &TIM_TimeBaseStructure);
    /* PWM2 Mode configuration: Channel2 */
    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
    TIM_OC2Init(TIM12, &TIM_OCInitStructure);
    TIM_OC2PreloadConfig(TIM12, TIM_OCPreload_Enable);
    TIM_ARRPreloadConfig(TIM12, ENABLE);

Thank you.