首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]dp256的atd0与atd1不能同时使用的问题

[求助]dp256的atd0与atd1不能同时使用的问题

要使用12路的ad转换,现在为atd的子程序中,经过了atd0和atd1的初始化,
只写了九路的程序,但第九路即atd1的AN8口始终无法正常工作,但单独使用atd0或者是
单独使用atd1时,是没有问题的,但两路一起用时却不正常,清高手指教.

#include /* common defines and macros */
#include /* derivative information */



/********** ATD0_init**********/

void ATD0_init(void)
{

//ATD0CTL2 = 0xC0; //AD模块上电,快速清零,无等待模式,跳变模式触发,禁止外部触发,关闭中断
ATD0CTL2 = 0x80; //选择normal AD模式;

/*ATD0CTL2_ADPU = 1; //normal ATD functionality;
ATD0CTL2_AFFC = 1; //all ATD conversion complete flags use fast clear mode;
ATD0CTL2_AWAI = 0; //disable ATD wait function;
ATD0CTL2_ETRIGLE = 0; //edge mode-active edge mode
ATD0CTL2_ETRIGP = 0; //active low level ro falliing edge active
ATD0CTL2_ETRIGE = 0; //disable external trigger mode;
ATD0CTL2_ASCIE = 0; //disable ATD interrupt;
ATD0CTL2_ASCIF = 0; //no ATD sequence complete interrupt occurred;read only
*/

//ATD0CTL3 = 0x00; //每个序列8次转换, No FIFO, Freeze模式下继续转换
ATD0CTL3 = 0x40; //每个序列8个转换;

/*ATD0CTL3_S8C = 0;
ATD0CTL3_S4C = 0;
ATD0CTL3_S2C = 0;
ATD0CTL3_S1C = 0; //conversion sequence length:8;
ATD0CTL3_FIFO = 0; //result registers maps to the conversion sequence;
ATD0CTL3_FRZ1 = 0;
ATD0CTL3_FRZ0 = 0; //ignore the background signal;
*/

//ATD0CTL4 = 0x03; //10位精度,2个时钟,
ATD0CTL4 = 0x03; //十位精度,2个时钟,8分频;

/*ATD0CTL4_SRES8 = 0; //10-bit resolution selected;
ATD0CTL4_SMP1 = 0;
ATD0CTL4_SMP0 = 0; //2 A/D clock periods;
ATD0CTL4_PRS4 = 0;
ATD0CTL4_PRS3 = 0;
ATD0CTL4_PRS2 = 0;
ATD0CTL4_PRS1 = 1;
ATD0CTL4_PRS0 = 1; //divided by 8;
*/

//ATD0CTL5 = 0xb0; //右对齐,无符号数,连续转换,多通道采样,从AD00开始
ATD0CTL5 = 0xB0; //右对齐,无符号数,连续转换,AD0到AD7通道;

/*ATD0CTL5_DJM = 1; //left justified mode;
ATD0CTL5_DSGN = 0; //unsigned result register data select;
ATD0CTL5_SCAN = 1; //perform conversion sequences continuously;
ATD0CTL5_MULT = 1; //sample only the specified channel;
ATD0CTL5_CC = 0;
ATD0CTL5_CB = 0;
ATD0CTL5_CA = 0; //MULT=1, the first channel to be examined in the conversion sequence;
*/

ATD0DIEN=0x00; //禁止数字输入

}

/********** ATD1_init**********/
void ATD1_init(void)
{
ATD1CTL2 = 0x80;
ATD1CTL3 = 0x08;
ATD1CTL4 = 0x03;
ATD1CTL5 = 0xB0;
ATD1DIEN=0x00;

}

/************ ATD_read ************/

void ATD_read(unsigned int temp[12]){

while(ATD0STAT0_SCF==0);
ATD0STAT0_SCF=1;
temp[0] = ATD0DR0;
//while(!ATD0STAT1_CCF1);
temp[1] = ATD0DR1;
//while(!ATD0STAT1_CCF2);
temp[2] = ATD0DR2;
//while(!ATD0STAT1_CCF3);
temp[3] = ATD0DR3;
//while(!ATD0STAT1_CCF4);
temp[4] = ATD0DR4;
//while(!ATD0STAT1_CCF5);
temp[5] = ATD0DR5;
//while(!ATD0STAT1_CCF6);
temp[6] = ATD0DR6;
//while(!ATD0STAT1_CCF7);
temp[7] = ATD0DR7;
while(!ATD1STAT1_CCF0);
temp[8] = ATD1DR0;

}
你为什么将ATD1设置为连续、多通道转换模式,同时又设置成每个序列仅一次转换?另外,ATD1的转换完成标志未采用快速清楚模式,所以,应该先读ATD1DR0,紧接着再读ATD1STAT1才能将上一次的CCF0清楚。
海纳百川  有容乃大
返回列表