/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Capture for TIM1

Username:     
Password:     
             

Forum

# 1   2009-10-19 06:48:19 Capture for TIM1

Fakhad
New member
Registered: 2009-07-14
Posts: 1

Capture for TIM1

I have STM32Primer2. I the layman in architecture of this system. I should measure duration of impulses coming on input IRDA (PORTA-> PA10). For what I wished to use TIM1. I have got confused in these 4 channel what of them is connected to input PA10. How correctly to initialize the timer 1 in a capture mode. Here my program but it works not correctly reads always 0:
*******************************************
  /* Configure PA.10 as input floating */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
//    GPIO_PinRemapConfig(GPIO_PartialRemap_TIM1,ENABLE);
    /* Configure GPIO_D Pin 8 = CS Irda */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
      // CS Irda  = 1
    GPIO_ResetBits(GPIOD, GPIO_Pin_8);
OldPLLFreq = UTIL_GetPll ();
    //Enable clock
    RCC_APB2PeriphClockCmd(
        RCC_APB2Periph_GPIOA |
        RCC_APB2Periph_GPIOD |
        RCC_APB2Periph_TIM1 |
        RCC_APB2Periph_AFIO |
        RCC_APB2Periph_USART1, ENABLE);
    UTIL_SetPll ( SPEED_VERY_HIGH );
        TI3_Config(TIM1,TIM_ICPolarity_Falling,TIM_ICSelection_DirectTI,0x03);
TIM_SetIC3Prescaler(TIM1,TIM_ICPSC_DIV1);

vu16 bpinput=0;
    //Begin synchronisation
    do
      {
      bpinput = (GPIOA->IDR)& ( GPIO_Pin_10 );
      }while (bpinput);
    //Start measurement
   uint16_t  tmp = 0;
  do
      {
        }while (!TIM_GetFlagStatus(TIM1, TIM_FLAG_CC3));
//end measurement
    tmp=TIM_GetCapture3(TIM1);//this capture time???
    TIM_ClearFlag(TIM1, TIM_FLAG_CC3);
    UTIL_uint2str( str, tmp , 6, 0 );
    DRAW_DisplayString(15,50,str,6);
    DRAW_SetTextColor(RGB_BLACK);
*************************************************************


Where my error?
How it is necessary to do?
Whether eats examples?
Help please.
Regards,
Farkhat

Last edited by Fakhad (2009-10-19 06:51:16)

Offline

 

Board footer