<address id="tnvjh"></address>
    <form id="tnvjh"><listing id="tnvjh"><meter id="tnvjh"></meter></listing></form>

      <form id="tnvjh"></form>

      <address id="tnvjh"><th id="tnvjh"></th></address>

        專注電子技術學習與研究
        當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

        PIC16F877定時器1的中斷方式調試

        作者:佚名   來源:不詳   點擊數:  更新時間:2014年08月31日   【字體:

        PIC16F877單片機定時器1使用中斷方式調試程序如下:

         #include<pic.h>

        #define uchar unsigned char
        #define uint  unsigned int
        __CONFIG(0x3B31);
        void init();
        uint intnum;
        void main()
        {
         init();
         while(1)
         {
         /* if(intnum >= 20)
          {
           intnum = 0;
           RD0 = !RD0;
          }*/
         }
        }
         
        void init()
        {
         TRISD = 0; //
         PORTD = 0; //PORTD輸出低電平
         INTCON = 0xC0;//開總中斷、定時器1中斷
         TMR1H = (65536-50000)/256;//預裝初值50ms*4
         TMR1L = (65536-50000)%256; 
         PIE1 = 0x01; //開定時器1中斷
         T1CON = 0x21; //1:4分頻,使能定時器1開始計數 
        /* TRISD=0;
         PORTD=0;
         INTCON=0xc0;
         PIE1=0x01;
         TMR1L=(65536-50000)%256;
         TMR1H=(65536-50000)/256;
         T1CON=0x21;*/
        }
         
        void interrupt time1()
        {
         TMR1IF=0; //定時器1溢出位清0
         TMR1L=(65536-50000)%256;
         TMR1H=(65536-50000)/256;
         //RD0=!RD0;//intnum++;
          if( ++intnum >= 20)
          {
           intnum = 0;
           RD0 = !RD0;
          }
        }
         
        總結:跟51定時器1相似。
        關閉窗口
        和老头做爰很舒服,JK白丝裤袜开裆自慰喷水,在线天堂www在线...中文

          <address id="tnvjh"></address>
          <form id="tnvjh"><listing id="tnvjh"><meter id="tnvjh"></meter></listing></form>

            <form id="tnvjh"></form>

            <address id="tnvjh"><th id="tnvjh"></th></address>