sri
Joined: 31 May 2010 Posts: 1
|
ADC conversion on dsPIC30F2011 |
Posted: Mon May 31, 2010 7:07 am |
|
|
Hi,
I am having trouble getting the ADC conversion to work on my dsPIC30F2011.
Code: |
#include <30F2011.h>
#fuses FRC, NOWDT, NOPROTECT, PUT16, NOBROWNOUT
#device adc=12
#use delay(clock=7370000)
int16 adc_value=0;
void main(void)
{
//SETUP Analog Channels
set_tris_b(0b00000001);
SETUP_ADC_PORTS(sAN0 | VSS_VDD);
SETUP_ADC(ADC_CLOCK_DIV_32);
do
{
SET_ADC_CHANNEL(0);
delay_ms(100);
READ_ADC(ADC_START_ONLY); //start converting
while (!adc_done())
{
}
adc_value=READ_ADC(ADC_READ_ONLY);
}
while(true);
}
|
The ADC doesn't work at all. When debugging and setting a breakpoint inside the loop. the value for adc_value doesn't settle. In fact each time I run and halt the program it adds 0d2 to the value, even if AN0 is set to 0V.
Please help. |
|