要怎樣利用訊號產生器產生方波用一隻腳位來讀取high low值
最近想要用訊號產生器產生一個方波訊號,再將這訊號接到腳位PA0上,如果讀到的訊號是high則將LED燈亮,如果是Low則滅。但是不知道哪裡出錯一直沒有辦法讀出訊號!所以想要請問我應該要怎麼修改呢?因為搞不太懂如果要接收訊號,那GPIO_Mode應該要怎麼設定呢?是IPU還是IPD呢?我以下的程式不知道是哪裡出錯呢? 謝謝
int main(void)
{
while (1)
{
Delay();
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1))
{ GPIO_SetBits(GPIOF,GPIO_Pin_0); // LED 會發光
}
else
{
GPIO_ResetBits(GPIOF,GPIO_Pin_0);// LED 熄滅
}
}
}
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
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);
}
顶,,,,,,,,,,,,,
页:
[1]