ADC dspic30f2012

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

ADC dspic30f2012

Postby bear » Sat May 26, 2012 3:11 pm

i use RB0 as vref
RB1 as AN1
RB2 as AN2


this is my code... the problem is nothing happen...

unsigned char read_adc(void)
{

ADPCFG = 0x01FF; //10th channel is sampled and coverted
ADCON1 = 0x0004; //ADC off, output_format=INTEGER
//Manual start of convesion
//Automatic start of sampling after coversion
ADCHS = 0x0001; //Connect RB10 on AN10 as CH0 input
ADCSSL = 0; //No scan
ADCON3 = 0x1003; //ADCS=3 (min TAD for 10MHz is 3*TCY=300ns)
ADCON2 = 0x2000; //Interrupt upon completion of one sample/convert
ADCON1bits.ADON = 1; //ADC on

ADCON1bits.SAMP = 1;
delay_ms(100); //Wait for 100ms (sampling ...)
ADCON1bits.SAMP = 0; //Clear SAMP bit (trigger conversion)
while(ADCON1bits.DONE == 0);

return ADCBUF0;
}
bear
Apprentice
 
Posts: 46
Joined: Tue Oct 05, 2010 2:11 am

Re: ADC dspic30f2012

Postby robosang » Mon May 28, 2012 5:08 pm

might be your hardware connection? Photo of your hardware setup would be good.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests

cron