当51单片机经过8255和锁存器74LS273来扩展IO时,常常用到头文件absacc.h。
在程序中,用“#include”即可运用其间界说的宏来访问肯定地址,包含:CBYTE、XBYTE、PWORD、DBYTE、CWORD、XWORD、PBYTE、DWORD
例如:
rval=CBYTE[0x0002];指向程序存贮器的0002h地址
rval=XWORD [0x0002];指向外RAM的0004h地址
KEIL 中ABSACC.H 界说如下:
#ifndef __ABSACC_H__
#define __ABSACC_H__
#define CBYTE ((unsigned char volatile code *) 0)
#define DBYTE ((unsigned char volatile data *) 0)
#define PBYTE ((unsigned char volatile pdata *) 0)
#define XBYTE ((unsigned char volatile xdata *) 0)
#define CWORD ((unsigned int volatile code *) 0)
#define DWORD ((unsigned int volatile data *) 0)
#define PWORD ((unsigned int volatile pdata *) 0)
#define XWORD ((unsigned int volatile xdata *) 0)
#ifdef __CX51__
#define FVAR(object, addr)
#define FARRAY(object, base) ((object volatile far *) (base))
#define FCVAR(object, addr)
#define FCARRAY(object, base) ((object const far *) (base))
#else
#define FVAR(object, addr)
#define FCVAR(object, addr)
#define FARRAY(object, base) ((object volatile far *) ((base)+0x10000L))
#define FCARRAY(object, base) ((object const far *) ((base)+0x810000L))
#endif
#endif
再如:
#define COM8255 XBYTE[0X060FF]
#define PA8255 XBYTE[0X000FF]
#define PB8255 XBYTE[0X020FF]
#define PC8255 XBYTE[0X040FF]