charlie22
驱动牛犊
驱动牛犊
  • 注册日期2002-08-05
  • 最后登录2007-11-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1341回复:5

调了两天都不通啊!!!(那边没人,只好过来问了)

楼主#
更多 发布于:2002-11-04 17:21
调了两天都不通啊!!!
硬件采用与52串口同步通信,即txd接7706-SCLK,rxd接7706的Din和Dout。(datasheet上的典型电路)

7706寄存器读写和初始化程序如下:
unsigned char read_7706()
{
unsigned char dat;
RI=0;
while(RI==0);
dat=SBUF;
return dat;
}

void write_7706(unsigned char dat)
{
TI=0;
SBUF=dat;
while(TI==0);
TI=0;
}


/*;*** AD7706 ANALOGUE TO DIGITAL CONVERTOR CONFIGURATION *********************************
;
;This is the AD7706 configuration routine
;
;The ADC configuration steps are as follows:
; 1)Write to the communications register specifying that the next operation to be a
; write to the clock register,select AIN1 (ie 0x20).
;
; 2)Write to the clock register appropiate settings (ie 0x0C)
; - Mclk out enabled
; - Input clock divided by two
; - Update rate of 20 ms or 50 Hz which gives
; a 3 dB digital filter cutoff of 13.1 Hz
;
; 3)Write to the comms register specifying that the next operation to be a write to
; the setup register and a calibration on channel 3 (ie 0x13)
;
; 4)Write to the setup register appropiate settings (0x54)
; - perform self calibration on channel 3
; - Gain of 4 (max input voltage 0.625 !!)
; - unipolar mode
; - on chip buffer enabled
; - clear Fsync to begin a conversion
*/
void init_7706()
{

write_7706(0x20); //1.write communication reg,next write clock reg
write_7706(0x0C); //2.write clock reg,

write_7706(0x08); //.write communication register,next read communication register
temp=read_7706(); //read communication register

write_7706(0x28); //next read clock register
temp=read_7706(); //read clock register

write_7706(0x10); //3.write communication register,next write set register
write_7706(0x40); //4.write set register

write_7706(0x08); //next read communication register
temp=read_7706(); //read communication register

write_7706(0x18); //next read set register
temp=read_7706(); //read set register


}

发现读出的寄存器值均为0xff,初始化不成功的。软硬件和资料是符合的啊,怎么会有这么奇怪的问题呢???

最新喜欢:

Jkw_DevJkw_De...
charlie22
驱动牛犊
驱动牛犊
  • 注册日期2002-08-05
  • 最后登录2007-11-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-11-04 17:22
不好意思,我问的是关于AD7706的使用,题目没有写清楚,sorry!
chengjian_hui
驱动小牛
驱动小牛
  • 注册日期2002-09-29
  • 最后登录2003-09-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-11-04 17:38
在付值语句中添加中间变量试一下啦。
ACC=SBUF;
dat=ACC;
不一定行的。
hglzw
驱动小牛
驱动小牛
  • 注册日期2001-06-12
  • 最后登录2006-03-03
  • 粉丝0
  • 关注0
  • 积分19分
  • 威望2点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
地板#
发布于:2002-11-05 12:06
我认为此接法绝对有问题,是不是你还没有真正理解。
rxd在作为通讯口时,只是一个输入信号啊,怎能和din/dout连在一块,又输入又输出呢?
你应该仔细研究一下时序。
会不会是,这两个管脚只是当作普通io使用?

[编辑 -  11/5/02 by  hglzw]
[img]http://www.kinboh.com/images/5130.jpg[/img]
chengjian_hui
驱动小牛
驱动小牛
  • 注册日期2002-09-29
  • 最后登录2003-09-16
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-11-05 16:27
呵呵,请看一下“有关D12端点读取的问题”,偶还是解决不了。
charlie22
驱动牛犊
驱动牛犊
  • 注册日期2002-08-05
  • 最后登录2007-11-28
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-11-06 10:31
我认为此接法绝对有问题,是不是你还没有真正理解。
rxd在作为通讯口时,只是一个输入信号啊,怎能和din/dout连在一块,又输入又输出呢?
你应该仔细研究一下时序。
会不会是,这两个管脚只是当作普通io使用?

[编辑 -  11/5/02 by  hglzw]


电路是没问题的,DS中的典型电路嘛。问题已经解决了,是时序问题,7706串口读写是先高字节后低字节,而52则是先低后高。所以要通过转换来实现每次读写。 昨天看时序图的时候突然发现的,呵呵。这种细节问题还真是麻烦人啊
游客

返回顶部