用寄存器做流水灯,这样写只是亮一秒就灭了,不会闪烁,
int main (void)
{
RCC_APB2ENR |= (1 << 3);
GPIOB_CRL &= ~((0x0f) << (4*0));
GPIOB_CRL |= ((0x03) << (4*0));
while(1)
{
GPIOB_ODR |= (0<<0);
Delay(1000);
GPIOB_ODR |= (1<<0);
}
}
int main (void)
{
RCC_APB2ENR |= (1 << 3);
GPIOB_CRL &= ~((0x0f) << (4*0));
GPIOB_CRL |= ((0x03) << (4*0));
while(1)
{
GPIOB_ODR ^= (0<<0);
Delay(1000);
GPIOB_ODR ^= (1<<0);
}
} |