AnsweredAssumed Answered

problem read input data

Question asked by claire.mutschler on May 10, 2012
Latest reply on May 10, 2012 by claire.mutschler
i am on the stm32l discovery and i send a square wave on the pin PA1 but it's like i don't receive it, i'm trying to read it with the function GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1) but it desn't work !!
int main(void){
    /*Configuration de la pin1 du portA(arriver du signal detection de traverse)*/
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
    GPIO_Init(GPIOA,&GPIO_InitStructure);
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_TIM2);
  TIM_InitStruct.TIM_Period = 849;
  TIM_InitStruct.TIM_Prescaler = PrescalerValue;
  TIM_InitStruct.TIM_ClockDivision = 0;
  TIM_InitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2,&TIM_InitStruct);
        /*timer2 chanel 2 pin PA1*/
    TIM_ICInitStruct.TIM_Channel = TIM_Channel_2;
    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 = 0x0;
    TIM_ICInit(TIM2, &TIM_ICInitStruct);
TIM_Cmd(TIM2, ENABLE);
    LCD_GLASS_Configure_GPIO();
    LCD_GLASS_Init();

  while (1){
      
    bitA = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1);
    sprintf(str," %u",bitA);
    LCD_GLASS_DisplayString( (unsigned char *) str );
  }
}

Outcomes