AnsweredAssumed Answered

STM32 Discovery Timer Reset problem

Question asked by chaitanya_cb on Feb 8, 2015
Latest reply on Feb 9, 2015 by Clive One
Hi,
I'm STM32F4-Discovery board and am trying to log GPS data into uSD card. I've configured the DMA and am able to view the data in the card. But, the data has gaps which was expected as the DMA interrupt is count based.

To avoid this I'm using Timer 2 to detect any transitions on the Rx line and configured the timer to reset mode. I want the transition on the line to reset the timer and start the count. Only on no activity, the timer would overflow and generate an interrupt.  Basically, some kind of time out interrupt.

However, the timer overflows and continuously generates the Update interrupt even when there is not activity on the line.

Here is the code I've used... Can you help where I went wrong.. Thanx in advance

void GPS_Gap_Timer_Config(void)
{
        
        GPIO_InitTypeDef                GPIO_InitStructure;
        TIM_TimeBaseInitTypeDef         TIMER_InitStructure;
        TIM_ICInitTypeDef               TIM_ICInitStruct;
        NVIC_InitTypeDef                NVIC_InitStructure;
        
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
 
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA , ENABLE);

        // PA8 = TIMER2_CHANNEL-1
        GPIO_PinAFConfig(GPIOA, GPIO_PinSource15,  GPIO_AF_TIM2);
 
        // Configure Port-A
        GPIO_InitStructure.GPIO_Pin     = GPIO_Pin_15;
        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_NOPULL;
        GPIO_Init(GPIOA, &GPIO_InitStructure);

        
        TIM_InternalClockConfig(TIM2);                                  //      Choose Internal Clock for Timer2
        
        TIMER_InitStructure.TIM_CounterMode     = TIM_CounterMode_Up;   //      Choose Up Mode Count
        TIMER_InitStructure.TIM_ClockDivision   = TIM_CKD_DIV4 ;        //      36MHz / 4 = 9MHz
        TIMER_InitStructure.TIM_Period          = 55000;
        TIMER_InitStructure.TIM_Prescaler       = 0;                    //      36MHz
        TIM_TimeBaseInit(TIM2, &TIMER_InitStructure);
                
        TIM_ICInitStruct.TIM_Channel            = TIM_Channel_1;
        TIM_ICInitStruct.TIM_ICPolarity         = TIM_ICPolarity_Rising;  
        TIM_ICInitStruct.TIM_ICSelection        = TIM_ICSelection_DirectTI;  
        TIM_ICInitStruct.TIM_ICPrescaler        = TIM_ICPSC_DIV1;  
        TIM_ICInitStruct.TIM_ICFilter           = 0;  
                
        TIM_ICInit(TIM2, &TIM_ICInitStruct);

        TIM_UpdateRequestConfig(TIM2, TIM_UpdateSource_Regular);
        
        TIM_SelectInputTrigger(TIM2, TIM_TS_TI1F_ED);
        TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);

        TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
                
        TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
        TIM_ITConfig(TIM2, TIM_IT_Trigger, DISABLE);
                
        NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
           
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
        
    
        TIM_Cmd(TIM2, ENABLE);

}



Outcomes