📄 ad_convert.c
字号:
/****************************************Copyright (c)**************************************************
********************************************************************************************************/
#define IN_ADCONVERT
#include "S3C2410.h"
#include "ad_convert.h"
/********************************************
* *funcition:send the converted value to queue
********************************************/
unsigned int read_value(void)
{
unsigned int ad;
ad = (unsigned int)rADCDAT0 & 0x3ff;
return ad;
}
/*******************************************
* *
*******************************************/
void AD_init(void)
{
rCLKCON |= 1<<15; //enable the ADC clock
}
/**********************************************
* *
**********************************************/
void start_adc(unsigned int chanel)
{
int i;
static int prevCh=-1;
unsigned int preScaler;
preScaler = 50000000/ADC_FREQ -1;
rADCCON = (1<<14) | (preScaler<<6) | (chanel<<3); //setup channel
rADCCON|=0x1; //start AD convert
//while(rADCCON & 0x1); //check if Enable_start is low
while(rADCCON & 0x1); //Check if Enable_start is low
while(!(0x8000&rADCCON)); //Check ECFLG
}
//---------------------------------------end------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -