#define ad1 0x50; //AD一通道 0-10V 输入 #define ad_addr XBYTE[0x8000] sbit HBEN = P1^0; //0 读高四位 1读低8位 sbit CS = P1^1; sbit INTF1 = P3^3; uint ad_vale; uint ad_command; uint read_ad197(uchar ad_command) { uint ad_vale; CS = 0; EA = 1; EX1 = 1; ad_addr = ad_command; while(INTF1 != 0) // while(IE1 == 0) { HBEN=0; } IE1 = 0; ad_vale = ad_addr; ad_vale = ad_vale << 8; HBEN = 1; ad_vale = ad_addr; return ad_vale; } |