ARM中关于设置寄存器的一点看法
#define rADCCON(*(volatile unsigned*)0x58000000) //ADC控制寄存器 #define rADCTSC(*(volatile unsigned*)0x58000004) //ADC触摸屏控制寄存器 #define rADCDLY(*(volatile unsigned*)0x58000008) //ADC启动或间隔延时寄存器 #define rADCDAT0(*(volatile unsigned*)0x5800000c) //ADC转换数据寄存器0 #define rADCDAT1(*(volati1e unsigned*)0x58000010) //ADC转换数据寄存器 void AD_Init(unsigned char ch){ rADCDLY=100; //ADC启动或间隔延时 rADCTSC=0; //选择ADC模式 rADCCON=(1<<14)|(49<<6)|(ch<<3)| (0<<2)|(0<<1)|(0); //设置ADC控制寄存器 } ......
关于设置ADC控制寄存器指令 : rADCCON=(1<<14)|(49<<6)|(ch<<3)| (0<<2)|(0<<1)|(0)
本文引用地址:https://www.eepw.com.cn/article/201611/317762.htm其含义是:
1左移(以0位为准)14位,即设置ADCCON中的PRSCEN为1:使能;
49左移6位,即前置分频器 分频数值为50(当前置分频器数值为N时,分频数值为N+1);
ch是变量,输入通道选择设置;
备用模式为正常模式;
禁止读操作启动;
AD转换不启动。
评论