AnsweredAssumed Answered

Why I can't use PA0 to get the function generator signal?

Question asked by sapphira on Feb 18, 2016
Latest reply on Feb 18, 2016 by sapphira
I used a function generator send a signal to PA1, if PA1 get the high signal that let LED on. But my program can't work correctly. Always high or always low, depend on GPIO_Mode = IPU or IPD. Below are my program, have any problem in my program! thanks!

int main(void)
{
    while (1)
    {
        Delay();
       if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1))
       {   GPIO_SetBits(GPIOF,GPIO_Pin_0);      // LED On
        }
       else
       {
            GPIO_ResetBits(GPIOF,GPIO_Pin_0);  // LED OFF  
        }
    }  
}

void GPIO_Configuration(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA,ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1  ;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOF,ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 ;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOF, &GPIO_InitStructure);    
}

Outcomes