16 bit 模数转换器
TM7705
图 20 TM7705 与 8xC51 接口
四十六、设置 TM7705 的程序代码
表 16 给出了 TM7705 和微控制器接口的用 C 代码写成的一组读、写程序。
此程序的几个步骤是:
1. 向通信寄存器写数据,选 择 通道 1 作为有效通道,将下一个操作设为对时钟寄存器
进行写操作。
2. 对时钟寄存器写操作,设置 CLK DIV 位,将外部时钟除二,假定外部时钟频率为
4.9512MHz ,更新率选为 50Hz。
3. 向通信寄存器写数据。选 择 通道 1 作为有效通道。将下一个操作设为对设置寄存器
的写操作。
4. 向设置寄存器写数据,将增益设为 1,设置为双极性、非缓冲模式,清除滤波器同
步,开始自校准。
5. 查询 DRDY 输出。
6. 从数据寄存器上读数据。
7. 跳回第 5、第 6 步,直到从选定的通道中取出指定数量的采样。
TM7705 与 68HC11 微处理器接口的 C 语言代码
表 16
/* This program hasreadand write routines for the 68HC11 to interfaceto the
TM7705 and the sampleprogram setsthe various registersand then reads1000
samplesfrom one channel.*/
#include <math.h>
#include <io6811.h>
#define NUM_SAMPLES 1000 /* changethe number of data samples*/
#define MAX_REG_LENGTH 2 /* this saysthat the max length of a register is 2
bytes*/
Writetoreg (int);
Read(int,char);
char *datapointer = store;
char store[NUM_SAMPLES*MAX_REG_LENGTH + 30];
void main()
©Titan Micro Electronics
www.titanmec.com
-36-