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 CCS Technical Support

PIC24 A/D don´t work

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



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PIC24 A/D don´t work
PostPosted: Wed Apr 15, 2009 11:23 am     Reply with quote

This is my code:

Code:
int16      LED_SPG;

   SETUP_ADC_PORTS(VSS_VDD | sAN3 );
   SET_ADC_CHANNEL(3);
   SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
   delay_us(100);
   LED_SPG = READ_ADC();


All registers seems to be right from CCS, but READ_ADC brings: 0xFFC0 in the watch window. In the ADC1BUF0 the value is 0x1023 (also incorrect!)

Whats wrong?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Apr 15, 2009 12:15 pm     Reply with quote

On some PIC24 devices, some JTAG configurations are incompatible with ADC operation, read the respective device errata sheet. There may be also problems with PCD built-in functions. Generally, PIC24 ADC operation is more complex than with other PIC devices, offering many options for misunderstandings and programming faults.
Tom B
Guest







Re: PIC24 A/D don´t work
PostPosted: Wed Apr 15, 2009 9:12 pm     Reply with quote

richi-d wrote:
This is my code:

Code:
int16      LED_SPG;

   SETUP_ADC_PORTS(VSS_VDD | sAN3 );
   SET_ADC_CHANNEL(3);
   SETUP_ADC(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
   delay_us(100);
   LED_SPG = READ_ADC();


All registers seems to be right from CCS, but READ_ADC brings: 0xFFC0 in the watch window. In the ADC1BUF0 the value is 0x1023 (also incorrect!)

Whats wrong?


Add the following to you your .h file
#device ADC=10
richi-d



Joined: 28 Aug 2007
Posts: 106

View user's profile Send private message

PostPosted: Sun Jul 05, 2009 4:17 am     Reply with quote

It works if I use programming port 2. See erata.

Thanks
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