写个简单的LED程序试下,发现LED不能闪烁。程序如下: u16 i = 10000; //SysTick_Config(SystemCoreClock / 1000); /* GPIOE Periph clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); /* Configure PA5 Pin output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_InitStructure); /* To achieve GPIO toggling maximum frequency, the following sequence is mandatory. You can monitor PE14 and PE15 on the scope to measure the output signal. If you need to fine tune this frequency, you can add more GPIO set/reset cycles to minimize more the infinite loop timing. This code needs to be compiled with high speed optimization option. */ while (1) { GPIO_SetBits(GPIOA, GPIO_Pin_5); while(i--); GPIO_ResetBits(GPIOA, GPIO_Pin_5); while(i--); } 请高手指点下。 |
延迟时间短吧,人眼能分辨的时间大于等于20MS,即50HZ以上的频率分辨不出来,延迟的短了,LED闪烁频率超过50HZ,人眼分辨不出来,看上去一直亮
{
i = 10000;
GPIO_SetBits(GPIOA, GPIO_Pin_5);
while(i--);
i = 10000;
GPIO_ResetBits(GPIOA, GPIO_Pin_5);
while(i--);
}