/****************DS1868 数字字电位器调试******************/
//注意:ds1868的管脚 调试是我用P2口的 5、6、7 脚 发现不好用
//另外线性效果也不是很理想,但是能够满足一般的要求了
#i nclude " reg51.h "
#i nclude " absacc.h "
#defineLSB 0x01
#defineHIGH1
#defineLOW0
#define BUZZER_OFF BUZZER=1
sbit DS1868_RST=P3^5;//pin 5
sbit DS1868_CLK=P3^6;//pin 6
sbit DS1868_DQ =P3^7;//pin 8
sbit BUZZER=P0^4;
void DS1868_communication(unsigned char potentiometer_1,unsigned char potentiometer_0);
void main(void)
{
BUZZER_OFF;
while(1)
{
DS1868_communication(0x55,0x55);
}
}
void DS1868_communication(unsigned char potentiometer_1,unsigned char potentiometer_0)
{
unsigned char i;
bit stack=1;
DS1868_RST=HIGH;
DS1868_DQ = stack;
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
for(i=0;i<8;i++)
{
DS1868_DQ=(bit)(potentiometer_1&LSB);
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
potentiometer_1>>=1;
}
for(i=0;i<8;i++)
{
DS1868_DQ=(bit)(potentiometer_0&LSB);
DS1868_CLK=HIGH;
DS1868_CLK=LOW;
potentiometer_0>>=1;
}
DS1868_RST=LOW;