#include "stm32f10x.h"void Delay(unsigned int x);
unsigned int TimingDelay;
int main(void)
{
SystemInit();//配置系統(tǒng)時(shí)鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);//使能APB2外設(shè)時(shí)鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD,ENABLE);//IO口使能設(shè)置
GPIO_InitTypeDef GPIO_InitStructure; //定義I/O口結(jié)構(gòu)體
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
if (SysTick_Config(72000000 / 100)) //每10ms中斷一次
{
while (1);
}
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_6);
Delay(100); //100*10ms=1s
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
Delay(100); //100*10ms=1s
}
}
void Delay(unsigned int x)
{
TimingDelay=x;
while(TimingDelay!=0);
}
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
//以下是報(bào)錯(cuò)函數(shù)
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
while (1)
{
}
}
#endif
評(píng)論