各位大侠版主:
我用得是s12dg128b得片子,通过AD采集传感器得信号,程序如下:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int i;
unsigned char * ADPointer[8];
unsigned int Sen_Read_Result[8];
#pragma CODE_SEG DEFAULT
void AD_Init(void){
ATD0CTL2 = 0xc0; //寄存器自动清零
ATD0CTL3 = 0x00; //转换序列长度为8
ATD0CTL4 = 0x88; // 8bit AD时钟8/9
ATD0CTL5 = 0x30; //连续多通道转换,左对齐
ATD0DIEN = 0x00; //禁止数字输入
ADPointer[0] = &ATD0DR0H;
ADPointer[1] = &ATD0DR1H;
ADPointer[2] = &ATD0DR2H;
ADPointer[3] = &ATD0DR3H;
ADPointer[4] = &ATD0DR4H;
ADPointer[5] = &ATD0DR5H;
ADPointer[6] = &ATD0DR6H;
ADPointer[7] = &ATD0DR7H;
}
void main(void) {
AD_Init();
EnableInterrupts;
for(i=0; i<8 ; i++) {
Sen_Read_Result = *ADPointer;
}
}
用codewarrior观察Sen_Read_Result得值,发现它是在无规律得变化着,小弟急等各位大侠得帮助! 谢谢了!
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |