写个简单的LED程序试下,发现LED不能闪烁。程序如下:
u16 i = 10000;
//Sys
tick_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--);
}
请高手指点下。
一周热门 更多>