AD5160引脚配置和功能描述
引脚配置图:

引脚功能描述:

AD5160外形尺寸

数字电位器AD5160测试程序
/********* STC12C5A60S2平台AD5160数字电位器程序 时钟:外部12M晶振
电位器串联外部电阻连接为可变电阻模式,若不串外部电阻直接接参考电压源即工作为数字电位计模式
*NOTE:作为可变电阻模式与外部电阻串联时存在一定程度容差,若所串电阻大于AD5160本身满量程电阻(型号有5K\10K\50K\100K)10倍以上则此容差才可忽略 *****/
/*AD5160.H*/
#ifndef _AD5160_H_ #define _AD5160_H_
#include《STC12C5A60S2.h》 #include《intrins.h》
typedef unsigned char uchar; typedef unsigned int uint;
sbit CPCS = P3^2; //数字电位器AD5160的片选CS,低电平有效 sbit SDI = P3^4; //数字电位器AD5160的数据SDI sbit SCK = P3^5; //数字电位器AD5160的时钟SCLK
void AD5160_init() //AD5160初始化 { CPCS = 1;
SCK = 0
SDI = 1;
}
void set_AD5160(uchar dat) //设定从W抽头到B端的抽头数,以10K版本的为 { //例电阻为RwB = 60+39*rdac 其中W抽头接触电阻为60Ω
uchar i,rdac=0; CPCS = 1;
rdac = dat; //RDAC为写入AD5160 内部8位radc寄存器数据 SCK = 0;
_nop_();_nop_();_nop_();_nop_();
SCK = 1; //SCK在CS拉低前触发一个时钟
_nop_();_nop_(); SCK = 0; _nop_();
CPCS = 0; //拉低CS启动数据写入 for(i=0;i《8;i++) { SDI = (rdac&0x80); rdac《《=1; //高位MSB在先 _nop_(); SCK = 1; _nop_(); SCK = 0; }
CPCS = 1;
_nop_(); //片选拉高后SCK送一个结束时钟,这点很重要 SCK = 1;
_nop_();_nop_(); SCK = 0; _nop_();
}
#endif
电子发烧友App


































评论