标题: error C202: 'P0_O': undefined identifier怎么改啊 [打印本页]

作者: sczlk    时间: 2021-1-14 18:55
标题: error C202: 'P0_O': undefined identifier怎么改啊
#include<reg52.h>
#include<stdio.h>
#define __nop()__asm nop__endasm


#define TRIGGER P0_O
#define ECHO P0_1


void delay()
{
        unsigned long int i;
        for(i=0;i<10000;i++);
}


int puchar (int c)
{
        while (!(SCON & 0x02));
        SCON &= -0x02;
        SBUF = c;
        return(c);        
}


void trigger()
{
        TRIGGER = 0;
        TRIGGER = 1;
        __nop();__nop();__nop();__nop();
        __nop();__nop();__nop();__nop();
        __nop();__nop();__nop();__nop();
        __nop();__nop();__nop();__nop();
        TRIGGER = 0;        
}


void calc()
{
        unsigned int duration,distance;
        duration = TH0*256 + TL0;
        duration *=12/11.0592;
        distance = duration * 0.017;
        printf("distance:%dcm\n",distance);
        TH0 = 0;
        TL0 = 0;
}


void setup()
{
        TMOD = 0x21;
        SCON = 0x40;
        TH1 = 0xFD;
        TCON = 0x40;
        
        SCON = 0x02;
        TH0 = 0;
        TL0 = 0;
        ETO = 1;
        EA = 1;
}


void loop()
{
        triiger();
        while(!ECHO);
        TR0 = 1;
        while (ECHO);
        TR0 = 0;
        calc();
        delay();
}


void main(void);
{
        setup();
        while (1)loop();
        
}





Part_08.c(24): error C202: 'P0_O': undefined identifier
Part_08.c(25): error C202: 'P0_O': undefined identifier
Part_08.c(30): error C202: 'P0_O': undefined identifier
Part_08.c(54): error C202: 'ETO': undefined identifier



作者: man1234567    时间: 2021-1-14 22:17
#define TRIGGER P0_O,这句机器读不懂
作者: 名字不是重点    时间: 2021-1-14 23:19
#define TRIGGER,这句你确定是“O”,而不是“0”?
应该是 P0_0或P0^0吧?
作者: 名字不是重点    时间: 2021-1-14 23:20
ETO还是错的,应是ET0
作者: cheney03    时间: 2021-1-15 09:02

#define TRIGGER P0_O
#define ECHO P0_1

改为 sbit TRIGGER=P0^0;
        sbit ECHO=P0^1;

ETO = 1;也有错,要改为ET0=1;





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1