微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 请问这个程序错的地方怎么改?

请问这个程序错的地方怎么改?

时间:10-02 整理:3721RD 点击:

程序:

#ifndef __ABSACC_H__

#define __ABSACC_H__

#define CBYTE ((unsigned char volatilecode  *) 0)

#define DBYTE ((unsigned char volatiledata  *) 0)

#define PBYTE ((unsigned char volatilepdata *) 0)

#define XBYTE ((unsigned char volatilexdata *) 0)

#define CWORD ((unsigned int volatilecode  *) 0)

#define DWORD ((unsigned int volatiledata  *) 0)

#define PWORD ((unsigned int volatile pdata*) 0)

#define XWORD ((unsigned int volatile xdata*) 0)

#ifdef __CX51__

#define FVAR(object, addr)   (*((object volatile far *) (addr)))

#define FARRAY(object, base) ((objectvolatile far *) (base))

#define FCVAR(object, addr)   (*((object const far *) (addr)))

#define FCARRAY(object, base) ((objectconst far *) (base))

#else

#define FVAR(object, addr)    (*((object volatile far *)((addr)+0x10000L)))

#define FCVAR(object, addr)   (*((object const far *) ((addr)+0x810000L)))

#define FARRAY(object, base)  ((object volatile far *) ((base)+0x10000L))

#define FCARRAY(object, base) ((objectconst far *) ((base)+0x810000L))

#endif

#endif

#include "adc0809.c"

#define LED_Data P2

#define A 10

#define U 11

sbit LED1=P3^0;

sbit LED2=P3^1;

sbit LED3=P3^2;

sbit LED4=P3^3;

sbit dp=P3^5;

#define LED_slect  P3

static uchar dispdata[4];

void decodenum(float adv,uchar chn)

{

uint temp;

temp=(uint)(adv*100);

dispdata[0]=temp/100;

dispdata[1]=temp/10%10;

dispdata[2]=temp%10;

dispdata[3]=chn;

}

void select(uchar LED)

{

  switch(LED)

     {

        case 0:LED1=0;break;

        case 1:LED2=0;break;

        case 2:LED3=0;break;

        case 3:LED4=0;break;

        default: LED_slect=0xff;

      }

}


void dispone(uchar LED,bit ifpoint,uchar number)   //,number 0--9

{

     select(LED);

     if(ifpoint)

          dp=1;

         else

          dp=0;

     LED_Data=num[number]|0x80;

delayus(200);

         LED_slect=0xff;

         }

void disp()

{

  uchar i;

  bit point;

for(i=0;i<4;i++)

   {

    if(i==1)

     point=0;

    else

     point=1;

    dispone(i,point,dispdata);

    }

}

#include <reg51.h>

#include<absacc.h>

#include "numcode.h"

#define uchar unsigned char

#define uint unsigned int

#define adin XBYTE[0x7fff]

void delayus(uint us)

{

  while(us--);

}

uchar ad_action(uchar chn)

{

  uchar read_data;

  adin=chn;

  delayus(6);

  read_data=adin;

  return read_data;

}

#ifndef __REG51_H__

#define __REG51_H__

/* BYTE Register  */

sfr P0  = 0x80;

sfr P1  = 0x90;

sfr P2  = 0xA0;

sfr P3  = 0xB0;

sfr PSW = 0xD0;

sfr ACC = 0xE0;

sfr B   = 0xF0;

sfr SP  = 0x81;

sfr DPL = 0x82;

sfr DPH = 0x83;

sfr PCON = 0x87;

sfr TCON = 0x88;

sfr TMOD = 0x89;

sfr TL0 = 0x8A;

sfr TL1 = 0x8B;

sfr TH0 = 0x8C;

sfr TH1 = 0x8D;

sfr IE  = 0xA8;

sfr IP  = 0xB8;

sfr SCON = 0x98;

sfr SBUF = 0x99;

/* BIT Register  */

/* PSW   */

sbit CY  = 0xD7;

sbit AC  = 0xD6;

sbit F0  = 0xD5;

sbit RS1 = 0xD4;

sbit RS0  = 0xD3;

sbit OV  = 0xD2;

sbit P   = 0xD0;

/* TCON  */

sbit TF1 = 0x8F;

sbit TR1 = 0x8E;

sbit TF0 = 0x8D;

sbit TR0 = 0x8C;

sbit IE1 = 0x8B;

sbit IT1 = 0x8A;

sbit IE0 = 0x89;

sbit IT0 = 0x88;

/* IE   */

sbit EA  = 0xAF;

sbit ES  = 0xAC;

sbit ET1 = 0xAB;

sbit EX1 = 0xAA;

sbit ET0 = 0xA9;

sbit EX0 = 0xA8;

/* IP   */

sbit PS  = 0xBC;

sbit PT1 = 0xBB;

sbit PX1 = 0xBA;

sbit PT0 = 0xB9;

sbit PX0 = 0xB8;

/* P3  */

sbit RD  = 0xB7;

sbit WR  = 0xB6;

sbit T1  = 0xB5;

sbit T0  = 0xB4;

sbit INT1 = 0xB3;

sbit INT0 = 0xB2;

sbit TXD = 0xB1;

sbit RXD = 0xB0;

/* SCON  */

sbit SM0 = 0x9F;

sbit SM1 = 0x9E;

sbit SM2 = 0x9D;

sbit REN = 0x9C;

sbit TB8 = 0x9B;

sbit RB8 = 0x9A;

sbit TI  = 0x99;

sbit RI  = 0x98;

#endif

unsigned char code num[]={

0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x3e

};

错误在哪儿?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top