接下来让我们配置相关代码(此次代码,源自新唐官方例程修改)
- #include "N76E003.h"
- #include "Common.h"
- #include "Delay.h"
- #include "SFR_Macro.h"
- #include "Function_define.h"
- void ADC_ISR (void) interrupt 11
- {
- if(ADCF)
- {
- clr_ADCF;//清除ADC转化完成标志,进行下一次转换
- set_ADCS;//当单次转换完成后,ADCS会硬件置0,需要重新使能
- printf ("\n Value = 0x%bx",ADCRH);//输出测量值高八位
- }
- }
- void main (void)
- {
- Set_All_GPIO_Quasi_Mode;
- InitialUART0_Timer1(9600);//串口0配置,引脚P06\07
- Enable_ADC_AIN6;//配置使能P03,作为AIN6。
- //P04_FALLINGEDGE_TRIG_ADC;// 使用P04下降沿触发中断,使 用外部触发时,可以不使能ADCS。
- set_EADC;//使能ADC中断
- EA = 1;
- set_ADCS;//使能ADCS,启动ADC测量
- while(1);
- }
|