GPIO的翻转速度指:输入/输出寄存器的0 ,1 值反映到外部引脚高低电平的速度.
代码在示例SampleCode\01_GPIO_Basic代码上修改而来,具体如下:
int main(void)
{
InitDelay();
InitDebug();
GPIO_LedInit();
GPIO_KeyInit();
TIMER_PrdInit();
printf("Hi This is GPIO Basic Demo !\r\n");
while (1)
{
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
GPIOA->ODR |= (1<<2);
GPIOA->ODR &= ~(1<<2);
// GPIO_ScanKeyInput();
// GPIO_ToggleLedPrd();
}
}
用示波器接到PA2上面,测得波形如下:
从波形上看,可以达到1.61MHz。GPIO寄存器好似没有速度调试的寄存器,如果是spi的状态下不知道可以达到多少速度。
|