175
第 8 章 模数转换模块(ADC)
8.8 ADC 转换应用举例
源程序代码:
(1)所需的复位和中断向量定义文件“vectors.asm”
// 该文件利用汇编语言代码定义了复位和中断向量
.title "vectors.asm"
.ref _c_int0,_nothing,_adint
.sect ".vectors"
reset: b _c_int0 // 复位向量
int1: b _adint // A/D 中断向量
int2: b _nothing
int3: b _nothing
int4: b _nothing
int5: b _nothing
int6: b _nothing
(2)主程序
// 该程序用于进行 A/D 转换的演示,A/D 转换的结果存于数足 ADRESULT[16]中,
// 寄存器 cesi 用于测试每个 A/D 转换的结果
#include "register.h"
int ADRESULT[16]; // 定义一个数组用于保存 AD 转换的结果
volatile unsigned int *j; // 定义一个指针变量 j
int i=0X00,cesi;
// 屏蔽中断子程序
void inline disable()
{
asm(" setc INTM");
}
// 开总中断子程序
void inline enable()
{
asm(" clrc INTM");
}
// 系统初始化子程序
void initial()
{