cancel
Showing results for 
Search instead for 
Did you mean: 

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

itri532600
Associate II
Posted on February 18, 2016 at 03:32

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);    

}

2 REPLIES 2
TDK
Guru
Posted on February 18, 2016 at 03:45

In one place you're initializing PA0, in the other you're reading PA1.  It's not exactly clear what isn't working for you, but it seems like those should match.

If you feel a post has answered your question, please click "Accept as Solution".
itri532600
Associate II
Posted on February 18, 2016 at 03:58

I fix the error! The read signal pin is PA1.

My program have any question for reading signal?