?? main.c
字號:
/* ADC模塊例程
HCS908_QG8 單片機開發板
實驗介紹:
本程序是ADC模塊的例程,所用資源為單片機內部ADC轉換模塊,
所接器件為電位器.確定你開發板上撥碼開關JP2(圖片上的6)的1位
處于on(這位是和電位器的連接),而其他位處于遠離on!
實驗現象:
在仿真界面的DATA1窗口中觀察mm的值是否隨電位器輸出值變化而變化
author:QGL
any question mail me:
libing.qu@free-tech.com.cn
*/
/*****************頭文件*****************************************/
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
/*********************變量和函數定義****************************/
unsigned int DATA;
void ADC_INI(void);
/*****************主函數*****************************************/
void main(void) {
EnableInterrupts; /* enable interrupts */
/* include your code here */
ADC_INI();
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
ADCSC1=0x20; //選擇通道號,使能adc轉換
while(!ADCSC1_COCO)//
__RESET_WATCHDOG();
DATA=ADCR;
ADCSC1=0x1f; //禁止ADC轉換
} /* loop forever */
/* please make sure that you never leave main */
}
/*****************adc中斷*****************************************/
interrupt 19 void ADC_INT(void) {
ADCSC1_COCO=0; // clear TOF清標志位
}
/*****************adc初始化*****************************************/
void ADC_INI(void) {
ADCSC1=0x20;//選擇通道號,使能ADC
ADCSC2=0x00;
ADCCFG = 0x49;//四分頻、10位模式、時鐘源為總線時鐘/2
APCTL1=0b00000001; //選擇管腳16(通道1)
ADCSC1=0x1f; //禁止 ADC
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -