看datasheet,没有发现专门的启动信号,好像只说写ATDCTL5可以start a new conversion,不太明白,是只要写一次ATDCTL5就能启动AD转换吗?想用查询方式读出转换结果,可是状态寄存器的值总不变,我觉得AD转换没有被启动。
请懂得人指点一下,谢谢!
我的程序如下,每次到if ((ATDSTAT1&0x01)==0x01)就判断不过去了,ATDSTAT1的值总是0x00,是不是说明根本没有开始进行转换呢?
请帮忙分析一下吧
#include
#include
#pragma LINK_INFO DERIVATIVE "mc9s12c32"
void ATDInit(void){
ATDCTL2 = 0x02; //Enable ATD sequence completion interrupt
ATDCTL3 = 0x22; //number of conversition per sequence is 4,non-FIFO mode
ATDCTL4 = 0x04; //10-bit resolution,second phase is 2 clock cycle,ATD clock is 800K
ATDDIEN = 0xFF; //disable digital input
}
#define RESULT_SIZE 20
void main(void) {
static unsigned char result[RESULT_SIZE];
unsigned char i = 0;
unsigned char rc;
ATDInit();
/* put your own code here */
EnableInterrupts;
for(;;) {
rc = ATDCTL5;
ATDCTL5 = 0x00;
if ((ATDSTAT1&0x01)==0x01)
{
result = ATDDR0H;
i++;
result = ATDDR0L;
i++;
}
} /* wait forever */
/* please make sure that you never leave this function */
}
[此贴子已经被作者于2006-12-18 15:32:51编辑过]
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |