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

QQ登錄

只需一步,快速開始

搜索
查看: 17315|回復(fù): 11
收起左側(cè)

error C264: intrinsic '_nop_': declaration/activation error keil編譯錯(cuò)誤

[復(fù)制鏈接]
ID:444914 發(fā)表于 2018-12-12 15:43 | 顯示全部樓層 |閱讀模式
這個(gè)問題怎么解決,單片機(jī)程序keil編譯出錯(cuò)
1212_2.jpg

錯(cuò)誤內(nèi)容:error C264: intrinsic '_nop_': declaration/activation error

單片機(jī)源程序如下:
#include <reg51.h>
#include <reg51.h>


sbit LCM_RS=P3^0;
sbit LCM_RW=P3^1;
sbit LCM_EN=P3^7;

#define BUSY                  0x80            
#define DATAPORT         P1
#define uchar                 unsigned char
#define uint                   unsigned int
#define L                        50

uchar str0[16],str1[16],count;
uint speed;
unsigned long time;

void ddelay(uint);
void lcd_wait(void);
void display();
void initLCM();
void WriteCommandLCM(uchar WCLCM,uchar BusyC);
void STR();
void account();



void int0_isr(void) interrupt 0         
{
    unsigned int temp;
        time=count;
    TR0=0;
        temp=TH0;
        temp=((temp << 8) | TL0);
    TH0=0x3c;
    TL0=0xaf;
        count=0;
    TR0=1;
        time=time*50000+temp;
}

void time0_isr(void) interrupt 1      
{
   TH0 =0x3c;
   TL0 =0xaf;
   count++;
}

void main(void)
{
           TMOD=0x01;                       
    IP|=0x01;                           
    TCON|=0x11;                        
    IE|=0x83;  
    TH0=0x3c;
    TL0=0xaf;

        initLCM();
           WriteCommandLCM(0x01,1);                    
        for(;;)
        {
                account();
                display();
        }
}

void account()
{
        unsigned long a;
        if (time!=0)
        {
                a=L*360000000/time;
        }
        speed=a;
}



void STR()
{
        str0[0]='S';
        str0[1]='p';
        str0[2]='e';
    str0[3]='e';
        str0[4]='d';
        str0[5]=' ';        
        str0[6]=(speed%100000)/10000+0x30;
        str0[7]=(speed%10000)/1000+0x30;
        str0[8]=(speed%1000)/100+0x30;
        str0[9]='.';
        str0[10]=(speed%100)/10+0x30;
        str0[11]=speed%10+0x30;
        str0[12]='k';
        str0[13]='m';
        str0[14]='/';
        str0[15]='h';
}

void ddelay(uint k)
{
    uint i,j;
    for(i=0;i<k;i++)
    {
        for(j=0;j<60;j++)
                {;}
    }
}

void WriteCommandLCM(uchar WCLCM,uchar BusyC)
{
    if(BusyC)lcd_wait();
        DATAPORT=WCLCM;
    LCM_RS=0;                 
    LCM_RW=0;                     
    LCM_EN=1;
        _nop_();
        _nop_();
        _nop_();
    LCM_EN=0;

}


void WriteDataLCM(uchar WDLCM)
{
    lcd_wait( );            
        DATAPORT=WDLCM;
    LCM_RS=1;            
    LCM_RW=0;                  
    LCM_EN=1;
    _nop_();
        _nop_();
        _nop_();
    LCM_EN=0;
}


void lcd_wait(void)
{
    DATAPORT=0xff;            
        LCM_EN=1;
    LCM_RS=0;
    LCM_RW=1;
    _nop_();
    _nop_();
        _nop_();
    while(DATAPORT&BUSY)
        {  LCM_EN=0;
           _nop_();
           _nop_();
           LCM_EN=1;
           _nop_();
           _nop_();
        }
           LCM_EN=0;

}

void initLCM( )
{
        DATAPORT=0;
        ddelay(15);
        WriteCommandLCM(0x38,0);   
    ddelay(5);
    WriteCommandLCM(0x38,0);
    ddelay(5);
    WriteCommandLCM(0x38,0);
    ddelay(5);

    WriteCommandLCM(0x38,1);   
    WriteCommandLCM(0x08,1);   
    WriteCommandLCM(0x01,1);   
    WriteCommandLCM(0x06,1);   
    WriteCommandLCM(0x0c,1);   
}


void DisplayOneChar(uchar X,uchar Y,uchar DData)
{
    Y&=1;
    X&=15;
    if(Y)X|=0x40;               
    X|=0x80;                    
    WriteCommandLCM(X,0);
    WriteDataLCM(DData);
}


void DisplayListChar(uchar X,uchar Y,uchar *DData)
{
    uchar ListLength=0;
    Y&=0x01;
    X&=0x0f;
    while(X<16)
    {
        DisplayOneChar(X,Y,DData[ListLength]);
        ListLength++;
        X++;
    }
}


void display()
{

        STR();
        DisplayListChar(0,0,str0);
           DisplayListChar(0,1,str1);
}


回復(fù)

使用道具 舉報(bào)

ID:1 發(fā)表于 2018-12-25 23:43 | 顯示全部樓層
#include <intrins.h> 添加這個(gè)頭文件就可以了。因?yàn)槟阌玫搅?_nop_();
回復(fù)

使用道具 舉報(bào)

ID:449525 發(fā)表于 2018-12-26 08:34 | 顯示全部樓層
嗯,添加
#include <intrins.h>
回復(fù)

使用道具 舉報(bào)

ID:385774 發(fā)表于 2022-10-10 13:27 | 顯示全部樓層
admin 發(fā)表于 2018-12-25 23:43
#include  添加這個(gè)頭文件就可以了。因?yàn)槟阌玫搅?_nop_();

謝謝哥們
回復(fù)

使用道具 舉報(bào)

ID:76027 發(fā)表于 2024-2-22 19:44 | 顯示全部樓層
我這里也出現(xiàn)同樣的問題,加了#include < intrins.h> 頭文件,還是報(bào)錯(cuò)。.\Core\eeprom.h(25): warning C206: '_nop_': missing function-prototype
回復(fù)

使用道具 舉報(bào)

ID:883242 發(fā)表于 2024-2-22 19:53 | 顯示全部樓層
bd5fna 發(fā)表于 2024-2-22 19:44
我這里也出現(xiàn)同樣的問題,加了#include < intrins.h> 頭文件,還是報(bào)錯(cuò)。.\Core\eeprom.h(25): warning C20 ...

你是分不清什么是C51什么是MDK造成的錯(cuò)誤。
回復(fù)

使用道具 舉報(bào)

ID:76027 發(fā)表于 2024-2-23 06:29 | 顯示全部樓層
Hephaestus 發(fā)表于 2024-2-22 19:53
你是分不清什么是C51什么是MDK造成的錯(cuò)誤。

請(qǐng)指教!
回復(fù)

使用道具 舉報(bào)

ID:76027 發(fā)表于 2024-2-23 08:32 | 顯示全部樓層
F:\Keil_v5\C51\Inc\intrins.h(19): error C231: '_nop_': redefinition
回復(fù)

使用道具 舉報(bào)

ID:155507 發(fā)表于 2024-2-23 11:47 | 顯示全部樓層
MDK 中插入空操作NOP

__asm void nop(void)
{
        NOP
}

void main()
{
.....

nop();

....

}
回復(fù)

使用道具 舉報(bào)

ID:76027 發(fā)表于 2024-2-23 12:04 | 顯示全部樓層
我這個(gè)是C51
回復(fù)

使用道具 舉報(bào)

ID:155507 發(fā)表于 2024-2-23 16:50 | 顯示全部樓層

如果要幫你查看問題,你就要吧程序貼出來(lái)
什么都沒有,人家想幫你也幫不上呀
回復(fù)

使用道具 舉報(bào)

ID:195496 發(fā)表于 2024-2-24 14:00 | 顯示全部樓層
貼上全文才能幫你編譯一下,查一下錯(cuò)誤原因
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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