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

QQ登錄

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

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

PIC16F877程序問(wèn)題

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:216579 發(fā)表于 2022-2-6 20:34 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include<pic.h>
#define uchar unsigned char
#define uint  unsigned int
__CONFIG(0x3B31);
void init();
uint intnum;
void main()
{       


        init();
        while(1)
        {
                if(intnum==5)
                {
                        intnum=0;
                        RD0=!RD0;
                }       
        }
}

void init()
{
        TRISD=0;
        PORTD=0;
        OPTION=0x07;   
        INTCON=0xa0;
        TMR0=61;
}

void interrupt time0()
{
        T0IF=0;
        TMR0=61;
        intnum++;
}



這是什么原因,程序?qū)懙臎](méi)有問(wèn)題啊



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

使用道具 舉報(bào)

沙發(fā)
ID:216579 發(fā)表于 2022-2-7 09:51 | 只看該作者

清除已成功 (總時(shí)間: 6ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/50331/Desktop/pic10f200/16F877_TMR0.X'
make  -f nbproject/Makefile-default.mk dist/default/production/16F877_TMR0.X.production.hex
make[2]: Entering directory 'C:/Users/50331/Desktop/pic10f200/16F877_TMR0.X'
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe"  -mcpu=16F877A -c   -mdfp="C:/Program Files/Microchip/MPLABX/v5.50/packs/Microchip/PIC16Fxxx_DFP/1.2.33/xc8"  -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/main.p1 main.c
::: advisory: (2049) C99 compliant libraries are currently not available for baseline or mid-range devices, or for enhanced mid-range devices using a reentrant stack; using C90 libraries
main.c:74:2: error: use of undeclared identifier 'OPTION'
        OPTION=0x07;
        ^
main.c:79:6: error: variable has incomplete type 'void'
void interrupt time0()
     ^
main.c:79:15: error: expected ';' after top level declarator
void interrupt time0()
              ^
              ;
3 errors generated.
(908) exit status = 1
nbproject/Makefile-default.mk:107: recipe for target 'build/default/production/main.p1' failed
make[2]: Leaving directory 'C:/Users/50331/Desktop/pic10f200/16F877_TMR0.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/50331/Desktop/pic10f200/16F877_TMR0.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/main.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

編譯已失敗 (退出值2, 總時(shí)間: 3s)
回復(fù)

使用道具 舉報(bào)

板凳
ID:1004618 發(fā)表于 2022-2-10 12:03 | 只看該作者
你試一下OPTION_REG呢
回復(fù)

使用道具 舉報(bào)

地板
ID:216579 發(fā)表于 2022-2-14 15:38 | 只看該作者

OPTION_REG可以,但中斷函數(shù)還是報(bào)錯(cuò)什么問(wèn)題
回復(fù)

使用道具 舉報(bào)

5#
ID:1019848 發(fā)表于 2022-12-27 13:53 | 只看該作者
XC8編譯器得用void __interrupt() ISR(void)
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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