哎,用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);
}
}
欢迎光临 (http://www.51hei.com/bbs/) | Powered by Discuz! X3.1 |