dsPIC33的ADC問題
|
||||
---|---|---|---|---|
新會員
|
想請教大家,我利用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
|
|||
|