標(biāo)題: pic16f877 tm0使LED每隔10ms閃亮代碼 [打印本頁]

作者: ssais    時間: 2018-10-15 11:12
標(biāo)題: pic16f877 tm0使LED每隔10ms閃亮代碼
/*
* File:   main.c
* Author: ssais
*
* Created on 2018年9月19日, 上午8:54
*/

#include <xc.h>
#define LED RB0
#define TO_10MS 100
char A;
void __interrupt() ISR(void);
void main() {
    TRISBbits_t.TRISB0=0;
    OPTION_REG=0b10000101;
    INTCON=0b10100000;
    TMR0=TO_10MS;
    LED=1;A=1;
    while(1);
    return;
}
////中斷服務(wù)
void __interrupt() ISR(void)
{
    if (INTCONbits.T0IF==1)
    {   INTCONbits.T0IF=0;
        TMR0=TO_10MS;
        if(A==1)
          {A=0;LED=0;}
        else
          {A=1;LED=1;}
    }   
   
}



作者: by64214    時間: 2018-11-15 12:27
謝謝分享  初學(xué)者  正在尋找練習(xí)程序例子
    我的是  MPLAB X IDE 5.05  XC8 2.0   編譯上述例程   沒有通過
  錯誤   error: expected identifier or '('
              TRISBbits_t.TRISB0=0;

make[2]: *** [build/default/production/main.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

編譯已失敗 (退出值2, 總時間: 274ms)
尋求幫助    謝謝




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1