• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: dsPIC33的ADC問題
#2
版主
版主


查看用戶資訊
要不要參考一下寫給 dsPIC33F128MC506 的 AD 例子:
void __attribute__((interruptno_auto_psv)) _ADC1Interrupt(void)
{

        
IFS0bits.AD1IF ;
        
MyADC ADC1BUF0>>;
}

void ADC_Initial(void)
{

     
AD1PCFGL 0xFFDF;        // AN5 is Analog , others are Digital;
     
AD1CON1 0x0446;    // 0b0000 0000 0100 0110 
                        // Auto convert using TMR3 as trigger source
                        // A/D Sample Auto-Start
     
AD1CON2 0x0000;    // ADCON2 = 0000 0000 0000 0000
                        // Don't scan inputs , SMPi = 00 ( Interrupt for each sample/convert )
     
AD1CSSL 0x0000;        // no scan input selected .......
     
AD1CON3 0x1F3F;        // TAD = 8 Tcy , SAMC = 15 TAD 
    
AD1CHS0 0x0005;    // ADCHS = 0b 00000000 00000101
    
AD1CON4 0x0000;

    
IFS0bits.AD1IF ;
    
IEC0bits.AD1IE ;        // Enable AD interrupt
    
IPC3bits.AD1IP ;    // Set Priority to 7     >> highest !!
 
     
AD1CON1bits.ADON 1;    // turn ADC ON
}

發表於: 2008/9/10 9:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsPIC33的ADC問題
#1
新會員
新會員


查看用戶資訊
想請教大家,我利用EXP16的AN5(內建VR的CH)讀取ADC
但將VR電壓轉到0時,ADC1BUF0卻都有0x1E4的值??
是哪裡有問題嗎?還請各位幫忙,謝謝!!
(程式是參照C30_Modules講義的自動取樣)


//-----------------------
//init_ports
//-----------------------
void INIT_PORTS(void)
{
// TRISB |= 0x0000; //PB.5=IN
}
//-----------------------
//init_ports
//-----------------------
void INIT_ADC(void)
{
IFS0bits.AD1IF = 0; // CLR AD INTR FLAG
IEC0bits.AD1IE = 0; // OFF AD INTR
AD1CON1bits.ADON = 0;

AD1CHS0 = 0x0005; // AN5=AD_IN
AD1CON1 = 0x04e4; // auto-convert(12bit)
AD1CON2 = 0x0000;
AD1CON3 = 0x1f3F; // 32·TCY = TAD 1f02
AD1CSSL = 0x0000;
AD1PCFGL = 0xFFDF; // AN5 is Analog , others are Digital(FFDF);
}
//-----------------------------------------------
//
//SUB PROGRAM
//
//-----------------------------------------------


//==================================
//Code Section in Program Memory
//==================================
main(void)
{
INIT_PORTS(); //Initialize the I/O ports
INIT_ADC();
//-----------------------
//
//MAIN LOOP
//
//-----------------------
while(1)
{
//-----------------------
//read adc
//-----------------------
AD1CON1bits.ADON = 1;
while(!AD1CON1bits.DONE);
AD1CON1bits.DONE = 0;
adc_buf=ADC1BUF0;

} // End of while()...

} // End of main()...

發表於: 2008/9/9 10:44
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... ]

教育訓練中心

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