请教马老师,用M64总线模式读取AD1674,读不出数据,附原程序,谢谢
程序用ICCAVR编译,用总线模式,用PROTEUS仿真看出AD输出有变化,但读入CPU再送显示时没有显示,(显示同样是用发光二极管);原程序和仿真文件在附件中,为方便查看,贴出部分程序
#include <iom128v.h>
#include <macros.h>
#include <stdlib.h>
#include <stdio.h>
#include "ad574.h"
#define F_CPU 8000000
#define CTRL (*(volatile unsigned char *)0x2FFF)
//控制口
#define ADSEL (*(volatile unsigned char *)0x4FFF)
unsigned int AD574value;
unsigned char hByte;
unsigned char lByte;
void AD574Convert(void)
{
unsigned int MSB , LSB;
unsigned char I=0;
// Start a conversion with A0 and A/$C$ low.
// The convesion takes place on rising CE edge.
CTRL= 0x00;
ADSEL = 0x00;
// Wait until we have completed a conversion .
while(I!=0x01)//STS==1?
{
I=PINB&0X01;
//delay_nus(5);
}
// Set R/$C$ with A0 low and read the low byte.
CTRL= 0x02;
hByte = ADSEL;
//PORTF=hByte;
// Set R/$C$ with A0 high and read the high.
CTRL= 0x03;
lByte = ADSEL;
//PORTF=lByte;
MSB=(unsigned int)(hByte << 4);
LSB=(unsigned int)(lByte >> 4);
// adc_Res now has the converted data with 12-bit resolution.
AD574value= MSB + LSB;
PORTF=AD574value;
//return;
}
void main(void)
{
unsigned int delay;
MCUCR=0X80;
DDRF = 0xFF;
PORTF = 0xFF;
DDRB=0X00;
PORTB=0X00;
while(1)
{
AD574Convert();
for (delay=0; delay<10000; delay++);
}
}
我的AD输出接PA口,控制线用PC口的A13,A14,A14直接控制AD的CS脚,所以地址是4FFF以上为程序,请指点,谢谢
ICCAVR原程序和PROTEUS仿真文件ourdev_293333.rar(文件大小:33K) (原文件名:ourdev_291373.rar) 再次请解答一下 http://cache.amobbs.com/bbs_upload782111/files_10/ourdev_296294.JPG
原理图 (原文件名:AD.JPG) 马老师,帮我解答一下吧,谢了 马老师不解答了,有没其他高手可以解答一下? 抱歉,AD1674没用过,另外也没有时间去仔细研究.你既然在PROTUSE模拟,可以单步执行,查看操作是否符合AD1674的规定,每次读到的数据是否正确. MARK 和AD1674有关,我找到的网上文件 给需要的人。顺便做个备份,我还没测试
点击此处下载 ourdev_568227G357GC.doc(文件大小:56K) (原文件名:ad1674.doc) 呵呵呵,两年还能找的到
页:
[1]