專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

PIC16F877定時(shí)器0的查詢方式調(diào)試

作者:佚名   來源:不詳   點(diǎn)擊數(shù):  更新時(shí)間:2014年08月31日   【字體:

 PIC16F877單片機(jī)定時(shí)器0的查詢方式調(diào)試程序如下:

 
#include<pic.h>
#define uchar unsigned char
#define uint  unsigned int
__CONFIG(0x3B31);
void init(void);
uint intnum;
void main(void)
{
 init();
 while(1)
 {
  if(T0IF)
  {
   T0IF = 0;
   if(++intnum >=1953)
   {
    intnum = 0;
    RD0 = !RD0;
   }
  }
 }
}
void init(void)
{
 TRISD = 0;  //PORTD引腳為輸出
 PORTD = 0;  //PORTD引腳為低電平
 OPTION = 0x08; //不分頻
 //TR//定時(shí)器0沒有啟停位
}
 
關(guān)閉窗口