访问电脑版页面

导航:老古开发网手机版其他

ds1868 c 驱动程序

导读:
关键字:
/****************DS1868 数字字电位器调试******************/

//注意:ds1868的管脚 调试是我用P2口的 5、6、7 脚 发现不好用
//另外线性效果也不是很理想,但是能够满足一般的要求了

#i nclude " reg51.h "
#i nclude " absacc.h "

#define  LSB  0x01
#define  HIGH 1
#define  LOW 0

#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;
}

来源:   作者:  2006/9/25 16:50:53
栏目: [ ]

相关阅读

安森美推出新的高功率图腾柱PFC控制器,满足具挑战的能效标准

动态功耗低至60μA/MHz!助力设备超长续航,首选国民技术低功耗MCU!