找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 2831|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

stm32時(shí)基定時(shí)器是用程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:86860 發(fā)表于 2015-7-26 02:19 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include "stm32f10x.h"


void Delay(unsignedint x);
unsigned intTimingDelay;
intmain(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(unsignedint x)
{


TimingDelay=x;
while(TimingDelay!=0);
}


voidTimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
   TimingDelay--;
}
}








//以下是報(bào)錯(cuò)函數(shù)
#ifdef USE_FULL_ASSERT
voidassert_failed(uint8_t* file, uint32_t line)
{
while (1)
{
}
}
#endif

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表