?? adc.c
字號(hào):
/*
* ADC.c
*/
#include <p24fj128ga010.h>
// initialize the ADC for single conversion, select Analog input pins
void initADC( int amask)
{
AD1PCFG = amask; // select analog input pins
AD1CON1 = 0x00E0; // auto convert after end of sampling
// AD1CON1 = 0x0004; // auto sample after conversion
AD1CSSL = 0; // no scanning required
AD1CON3 = 0x1F02; // max sample time = 31Tad, Tad = 3 x Tcy >75ns
AD1CON2 = 0; // use MUXA, AVss and AVdd are used as Vref+/-
AD1CON1bits.ADON = 1; // turn on the ADC
} //initADC
int readADC( int ch)
{
AD1CHS = ch; // select analog input channel
AD1CON1bits.SAMP = 1; // start sampling, automatic conversion will follow
while (!AD1CON1bits.DONE); // wait to complete the conversion
return ADC1BUF0; // read the conversion result
} // readADC
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -