Browsing this Thread:
1 Anonymous Users
|
dsPIC2020 ADC PROPLEMS
|
|
新會員
Joined
: 2009/2/18 23:20 最後登入時間
: 2009/6/15 15:02
Group:
註冊會員
Level : 1 HP : 0 / 15 MP : 2 / 688 EXP : 60
|
各位大大 你們好!! 我現在有個dsPIC2020 ADC部分的問題。我有4的外部信號要進dsPIC的 AN0~AN3, 我在程式部分要分別去讀取這四個信號,但是如果只是分別讀AN0和AN1 或者是AN2和AN3 用示波器去看都沒有錯 但是如果要一次讀取這四個信號他就只有轉換AN0和AN1的信號 而AN2和AN3的信號都沒有被轉換。我是採用軟體觸發轉換的方式。謝謝!!
我的ADC暫存器設定如下: void Init_ADC(void) { IEC2bits.ADCP0IE = 0 ; IFS2bits.ADCP0IF = 0 ; ADCON = 0x0023 ; ADPCFG = 0xFFF0 ; ADSTAT = 0x0000 ; ADCPC0 = 0x8181 ; ADCONbits.ADON = 1 ; } 主程式內容如下: int main(void) { TRISE = 0x0000; TRISBbits.TRISB5 = 0; Init_ADC(); while(1) { ADCPC0bits.SWTRG0 = 1 ; ADCPC0bits.SWTRG1 = 1 ; if(!ADCPC0bits.PEND0); ZL1 = ADCBUF0 >> 2 ; IL1 = ADCBUF1 >> 2 ; if(!ADCPC0bits.PEND1) ZC1 = ADCBUF2;
ADCPC0bits.SWTRG0 = 1 ; ADCPC0bits.SWTRG1 = 1 ; if(!ADCPC0bits.PEND0); ZL2 = ADCBUF0 >> 2 ; IL2 = ADCBUF1 >> 2 ; if(!ADCPC0bits.PEND1) ZC2 = ADCBUF2; if((ZL1 + ZL2)*0.5 >= 100) LATE = (-1*(IL1 + IL2)*0.5*0.0032258*4*25)+128; else LATE = (1*(IL1 + IL2)*0.5*0.0032258*4*25)+128; if((ZC1-ZC2) >= 100) LATBbits.LATB5 = 1; else LATBbits.LATB5 = 0; } }
發表於: 2009/5/3 23:11
|
|
You can view topic.
你 不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.