哎,用52單片機來搞了個max530(12位DA)的程序 但是卻無法實現轉換,,,頭大。。。。附上程序,求大俠們幫幫忙。 #include"reg52.h" //#include"absacc.h" //#define MAX530 XBYTE[0x7fff] #define uchar unsigned char ; #define uint unsigned int; uint code tab2[]={2048,0}; sbit A0=P1^0; sbit A1=P1^1; sbit LDAC=P1^2; sbit CLR=P1^3; sbit cs=P1^4; uchar Hbuf; uchar Lbuf; void delay(int m) { int i,j; for (i=0;i<m;i++); } void WriteMax530(int cnt) { CLR=1; CLR=0; CLR=1; LDAC=1; Lbuf=cnt&0xff; // 低八位 Hbuf=(cnt>>8)&0xff; //高四位 A0=1; A1=1; // MAX530=Lbuf; cs=1; cs=0; P0=Lbuf; cs=1; //delay(5); //LDAC=0; // LDAC=1; A0=0; A1=0; // MAX530=Hbuf; cs=1; cs=0; P0=Hbuf; cs=1; delay(5); LDAC=0; LDAC=1; } void main() { while(1){ WriteMax530(4095); } } |