AnsweredAssumed Answered

generate one pulse

Question asked by junjie.kong.001 on Jul 8, 2011
Latest reply on May 1, 2013 by Clive One
I am trying to generate a single pulse using the TIM_SelectOnePulseMode() function in STM32f10x_tim.c source file. But I am not able to get the pulse. why?

I am using TIM4 CH2... Any advice?

int main(void)
{
    TIM_Cmd(TIM4, DISABLE);

    RCC_Configuration();

    GPIO_Configuration();

    PrescalerValue = (SystemCoreClock / 24000000) - 1;
   
    TIM_TimeBaseStructure.TIM_Period = 65535
    TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue
    TIM_TimeBaseStructure.TIM_ClockDivision = 0;
    TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);

    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_Pulse = 16383
    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

    TIM_OC2Init(TIM4, &TIM_OCInitStructure);

    TIM_Cmd(TIM4, ENABLE);

    TIM_SelectOnePulseMode(TIM4, TIM_OPMode_Repetitive);

    return 0;
}

void RCC_Configuration(void)
{
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE);
}


void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_Init(GPIOD, &GPIO_InitStructure);

Outcomes