找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 15329|回复: 11
打印 上一主题 下一主题
收起左侧

error C264: intrinsic '_nop_': declaration/activation error keil编译错误

[复制链接]
跳转到指定楼层
楼主
这个问题怎么解决,单片机程序keil编译出错


错误内容:error C264: intrinsic '_nop_': declaration/activation error

单片机源程序如下:
#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);
}


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1 发表于 2018-12-25 23:43 | 只看该作者
#include <intrins.h> 添加这个头文件就可以了。因为你用到了 _nop_();
回复

使用道具 举报

板凳
ID:449525 发表于 2018-12-26 08:34 | 只看该作者
嗯,添加
#include <intrins.h>
回复

使用道具 举报

地板
ID:385774 发表于 2022-10-10 13:27 | 只看该作者
admin 发表于 2018-12-25 23:43
#include  添加这个头文件就可以了。因为你用到了 _nop_();

谢谢哥们
回复

使用道具 举报

5#
ID:76027 发表于 2024-2-22 19:44 | 只看该作者
我这里也出现同样的问题,加了#include < intrins.h> 头文件,还是报错。.\Core\eeprom.h(25): warning C206: '_nop_': missing function-prototype
回复

使用道具 举报

6#
ID:883242 发表于 2024-2-22 19:53 | 只看该作者
bd5fna 发表于 2024-2-22 19:44
我这里也出现同样的问题,加了#include < intrins.h> 头文件,还是报错。.\Core\eeprom.h(25): warning C20 ...

你是分不清什么是C51什么是MDK造成的错误。
回复

使用道具 举报

7#
ID:76027 发表于 2024-2-23 06:29 | 只看该作者
Hephaestus 发表于 2024-2-22 19:53
你是分不清什么是C51什么是MDK造成的错误。

请指教!
回复

使用道具 举报

8#
ID:76027 发表于 2024-2-23 08:32 | 只看该作者
F:\Keil_v5\C51\Inc\intrins.h(19): error C231: '_nop_': redefinition
回复

使用道具 举报

9#
ID:155507 发表于 2024-2-23 11:47 | 只看该作者
MDK 中插入空操作NOP

__asm void nop(void)
{
        NOP
}

void main()
{
.....

nop();

....

}
回复

使用道具 举报

10#
ID:76027 发表于 2024-2-23 12:04 | 只看该作者
我这个是C51
回复

使用道具 举报

11#
ID:155507 发表于 2024-2-23 16:50 | 只看该作者

如果要帮你查看问题,你就要吧程序贴出来
什么都没有,人家想帮你也帮不上呀
回复

使用道具 举报

12#
ID:195496 发表于 2024-2-24 14:00 | 只看该作者
贴上全文才能帮你编译一下,查一下错误原因
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表