代码实现#include <led.h>
#include <stm32f10x.h>
#include <sys.h>
//配置systick 寄存器
void SysTick_Configuration(void)
{
SysTick->VAL = 0;
SysTick->LOAD = (72000000/8000000)*1000;//´ú±íÿ¸ömsÐèÒªµÄ9000¸ösystickʱÖÓÊý
SysTick->CTRL |= 0x06;
}
//中断处理函数
void SysTick_Handler(void) //????
{
extern unsigned long TimingDelay; // ????,?????????
SysTick->VAL = 0;
if (TimingDelay != 0x00)
TimingDelay--;
}
//systick延时函数
unsigned long TimingDelay; //
void Delay(unsigned long nTime) //
{
SysTick->CTRL |=0x07; //
TimingDelay = nTime; //
while(TimingDelay != 0); //
SysTick->CTRL |=0x06;//
}
int main()
{
SystemInit(); //??(??)???
LED_Init();
SysTick_Configuration(); //??systick???
while(1)
{
GPIOA->ODR|=1<<8;
GPIOD->ODR|=1<<2;
Delay(1000); //1S
GPIOA->ODR&=~(1<<8);
GPIOD->ODR&=~(1<<2);
Delay(1000); //1S
}
}
|