AnsweredAssumed Answered

Stm32F3 PWM input

Question asked by schmid.michael.004 on Jan 22, 2014
Latest reply on Jan 27, 2014 by schmid.michael.004
Hi,

I've got some problems with my F3Discovery. I have a perfectly working TIM2 PWM-input-capture, but if I want to change it to timer1 it does not call the interrupt handler at all anymore.
The code for the initialisation is:
void PwmInputInit(void)
{
    TIM_ICInitTypeDef  TIM_ICInitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
     
     
    /* TIM1 clock enable */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);
     
    /* GPIOA clock enable */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
     
    /* TIM1 channel1 configuration : PA.08 */
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_8;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP ;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
     
    /* Connect TIM pin to AF2 */
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_2);
     
    /* Enable the TIM1 CC Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1 ;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
 
 
    TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
    TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
    TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
    TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
    TIM_ICInitStructure.TIM_ICFilter = 0x0;
 
    //dont know which is right, neither works...
    TIM_ICInit(TIM1, &TIM_ICInitStructure);
    //TIM_PWMIConfig(TIM1, &TIM_ICInitStructure);
 
    /* Select the TIM1 Input Trigger: TI2FP2 */
    TIM_SelectInputTrigger(TIM1, TIM_TS_TI1FP1); // not sure, none of them works
 
    /* Select the slave Mode: Reset Mode */
    TIM_SelectSlaveMode(TIM1, TIM_SlaveMode_Reset);
    TIM_SelectMasterSlaveMode(TIM1,TIM_MasterSlaveMode_Enable);
 
    /* TIM enable counter */
    TIM_Cmd(TIM1, ENABLE);
 
 
    /* Enable the CC1 Interrupt Request */
    TIM_ITConfig(TIM1, TIM_IT_CC1, ENABLE);
}

and the Interrupt handler (which is never called) is only

void TIM1_CC_IRQHandler(void)
{
  STM_EVAL_LEDOn(LED7);
}

Anybody can help me which initialisation I forgot?


Thanks,

Michael

Outcomes