我的程序如下,每次到if ((ATDSTAT1&0x01)==0x01)就判断不过去了,ATDSTAT1的值总是0x00,是不是说明根本没有开始进行转换呢? 请帮忙分析一下吧
#include /* common defines and macros */ #include /* derivative information */ #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编辑过] |