請問一下
我轉換三個CH(CH1,CH2,CH3)
分別是從dsPIC30F4012的AN3,AN4,AN5輸入
參考電壓是AVDD和AVSS
是用10MHz(石英震盪器) *8(倍頻)=80MHz=Fosc
所以Fcy =20MHz
我期望整個A/D取樣三個CH完成的時間是在0.001S內完成
使用手動取樣和轉換
是用同時取樣 非順序取樣的方法
///////////////////////////////////////////////
void ADC10_Initial(void)
{
ADPCFG=0xffc7; //AN3,AN4,AN5 are Analog
ADCON1=0x200c;// 數據輸出格式是整數
// Auto convert by yourself
// Auto A/D Sample by yourself
ADCON2=0x0308;// 參考電壓是AVDD和AVSS
// 轉換3次便執行ADC中斷
//只使用MUXA
//使用16bit的暫存器(不分兩個8-8)
ADCSSL=0;// no scan input selected
ADCON3=0x1f07;// TAD = 7 Tcy , SAMC = 31 TAD
//這一項我就不清楚有沒有算錯
ADCHS = 0x0022 ;//CH0-AN2(not used),CH1-AN3,CH2-AN4,CH3-AN5
IEC0bits.ADIE=1 ;// Enable AD interrupt
IPC2bits.ADIP=7 ;// Set Priority to 7 >> highest !!
ADCON1bits.ADON=1;// Enable the A/D
}
////////////////////////////////////////////////
void _ISR _ADCInterrupt(void)
{
int i;
float temp[3];
IFS0bits.ADIF = 0 ;
while(!ADCON1bits.DONE); //轉換完成了嗎?
temp[0]=ADCBUF0; // AN3 is analog input
temp[1]=ADCBUF1; // AN4 is analog input
temp[2]=ADCBUF2; // AN5is analog input
}
PS.temp是我最後希望A/D轉換後得到的值
請問各位大大
這樣有錯誤嗎
因為我找不到要用什麼方法確定這程式對不對
執行都OK但是就是不知它ADCBUF裡面的直到底是不是我外部電壓A/D後的值?