#include<stm32f10x_lib.h>
//定义区
//____________________________________________________________________________
u16 PortE;
//Led初始化
//_______________________________________________________________________________
void Led_Init(void){
RCC->APB2ENR|=1<<7; // 使能PORTE时钟
GPIOF->CRL&=0; GPIOF->CRL|=0x33333333; //PORTE低八位推挽输出
}
//延时
//__________________________________________________________________________________
void Delay(u16 counter){
while(--counter){
u16 i=2000;
while(--i);
}
}
//主函数
//__________________________________________________________________________________
int main(void){
Led_Init();
for(;;){
//低至高移八位
GPIOF->ODR=0xfe;
Delay(300);
GPIOF->ODR=0xfd;
Delay(300);
GPIOF->ODR=0xfb;
Delay(300);
GPIOF->ODR=0xf7;
Delay(300);
GPIOF->ODR=0xef;
Delay(300);
GPIOF->ODR=0xdf;
Delay(300);
GPIOF->ODR=0xbf;
Delay(300);
GPIOF->ODR=0x7f;
Delay(300);
}
}
|