• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






dsPIC2020 ADC PROPLEMS
#1
新會員
新會員


查看用戶資訊
各位大大 你們好!!
我現在有個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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







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.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------