我是用I/O口模拟来实现的,单片机为89C52,但是我发现数字电位器的输出端 W 根本没有数据输出,哪位大哥大姐能给指导一下,感激不尽! #include <reg52.h> #include <intrins.h> #include <absacc.h> #define uchar unsigned char #define uint unsigned int sbit MAX5483_CS = P1^5; sbit MAX5483_SCLK = P1^6; sbit MAX5483_DIN = P1^7; //max5483 void max5483write(uchar direct,uchar data1,uchar data2); void main() { max5483write(0x00,0xf4,0x00); } void max5483write(uchar direct,uchar data1,uchar data2) { uchar i; MAX5483_SCLK = 0; MAX5483_CS=0; for (i=0;i<8;i++) //上升沿写入命令 { MAX5483_SCLK =0; MAX5483_DIN = (bit)(direct&0x80); direct = direct<<1; MAX5483_SCLK =1; } for (i=0;i<8;i++) //上升沿写入数据 { MAX5483_SCLK =0; MAX5483_DIN = (bit)(data1&0x80); data1 = data1<<1; MAX5483_SCLK =1; } for (i=0;i<8;i++) //上升沿写入数据 { MAX5483_SCLK =0; MAX5483_DIN = (bit)(data2&0x80); data2 = data2<<1; MAX5483_SCLK =1; } MAX5481_CS=1; }
|