CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ADC conversion on dsPIC30F2011

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sri



Joined: 31 May 2010
Posts: 1

View user's profile Send private message

ADC conversion on dsPIC30F2011
PostPosted: Mon May 31, 2010 7:07 am     Reply with quote

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.
Question

Please help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group