AD7707 PIC程序 - cpubbs虚拟仪器论坛 - cpubbs论坛免费虚拟仪器博客 labview虚拟仪器讨论区 - cpubbs论坛 虚拟仪器论坛|labview论坛|labwindows论坛|vi|cvi|数据采集卡|入门教程|初学|软件下载|虚拟仪器免费博客|虚拟仪器电子商务|虚拟仪器商城|虚拟仪器人才中心|图形化单片机编程cpuview|虚拟仪器在线商城 - Powered by X-Space
cpubbs论坛,专业的labview,labwindows,虚拟仪器数据采集卡交流论坛,免费博客,人才中心,电子商贸,欢迎您的光临!

AD7707 PIC程序

上一篇 / 下一篇  2008-03-03 21:29:29 / 个人分类:转载类

原贴地址:

http://user.chol.com/smarty/bbs/bbs.php?page=4&id=ascbbs&db=homefirmware&s_category=&s_type=&s_keyword=&p=view&uid=44

 

// Driver routines for the AD7707 chip

#define AD7707_DRDY PIN_B0
#define AD7707_DO PIN_B1
#define AD7707_DI PIN_B2
#define AD7707_CLK PIN_C0
#define AD7707_CS PIN_C1
#define AD7707_RESET PIN_C2

void AD7707_write_byte(byte data)
{
byte i;

output_low(AD7707_CS);

for(i=1;i<=8;++i) {
output_low(AD7707_CLK);
output_bit(AD7707_DI, shift_left(&data,1,0));
output_high(AD7707_CLK);
}
output_high(AD7707_CS);
}

void AD7707_init()
{

output_low(AD7707_RESET);
output_high(AD7707_CLK);
output_high(AD7707_RESET); //Set high to AD7715 reset low pin
output_high(AD7707_CS); //Set low to AD7715 chip select low pin
delay_ms(100);

//0DRDY/RS2/RS1/RS0/RW/STBY/CH1/CH0
// 0 / 0 / 1 / 0 /0 / 0 / 1 / 1 // 0x13 : Ch3狼 clock write operation
AD7707_write_byte(0x23); //Communications Register
//zero/zero/clkdis/clkdiv/clk/fs2/fs1/fs0
// 0 / 0 / 0 / 1 / 0 / 0 / 0 / 0
AD7707_write_byte(0x10); //Clock Register

//0DRDY/RS2/RS1/RS0/RW/STBY/CH1/CH0
// 0 / 0 / 0 / 1 /0 / 0 / 1 / 1 // 0x13 : Ch3狼 setup register write operation
AD7707_write_byte(0x13); //Communications Register
// MD1/MD0/G2/G1/G0/BU/BUF/FSYNC
// 0 / 1 / 0/ 0/ 0/ 0/ 0 / 0 // Gain=1 bipolar, buffer off,
AD7707_write_byte(0x40); // Setup register

while(input(AD7707_DRDY));
}

long int AD7707_read_word(void)
{
byte i;
long data;

output_low(AD7707_CS);
for(i=1;i<=16;++i) {
output_low(AD7707_CLK);
output_high(AD7707_CLK);
shift_left(&data,2,input(AD7707_DO));
}
output_high(AD7707_CS);
return data;
}

long int AD7707_read_value(void)
{
//0DRDY/RS2/RS1/RS0/RW/STBY/CH1/CH0
// 0 / 0 / 1 / 1 /1 / 0 / 1 / 1 // 0x38 : Ch3狼 Data Register read operation
AD7707_write_byte(0x3B); // Data Register ch3 read operation
while(input(AD7707_DRDY));

return AD7707_read_word();
}


TAG: PIN output PIC define CLK

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2024-05-07  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 33687572
  • 日志数: 168
  • 图片数: 6
  • 影音数: 5
  • 商品数: 4
  • 文件数: 105
  • 建立时间: 2006-11-02
  • 更新时间: 2016-04-08

RSS订阅

Open Toolbar