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 not used VREF

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



Joined: 28 Apr 2011
Posts: 2

View user's profile Send private message

PIC24 not used VREF
PostPosted: Thu Apr 28, 2011 4:14 pm     Reply with quote

Hi,
I use PIC24HJ64GP206 and CCS compiler version 4.114.
I want to measure ADC modules using Vref (I use 2.5V), but whatever I do ADC module uses Vdd. Here is some code I use.
Thank you in advance if anyone can help.
Code:

void main(){
   setup_adc_ports(AN0_TO_AN1|VSS_VREF);
   setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_4);

VSS_VREF - for PIC18 work correctly, PIC24 does not work
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Apr 29, 2011 7:40 am     Reply with quote

Yes, reference voltage selection is among the PIC24 features, that still aren't implemented correctly in PCD, also in most recent V4.120. File a bug report to CCS support and set the respective configuration bits in ADxCON2 directly.
Bingo



Joined: 28 Apr 2011
Posts: 2

View user's profile Send private message

PostPosted: Fri Apr 29, 2011 4:16 pm     Reply with quote

Problem is solved, if anyone needs an example here:

#bit VCFG_BIT = 0x0322.13 // Define address of VCFG bit

void main()
{
setup_adc_ports(sAN1 | sAN2 | sAN3 | sAN4|VSS_VREF);
setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_4);

VCFG_BIT = 1; // Enable the Vref pin
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Apr 30, 2011 3:55 am     Reply with quote

Quote:
Problem is solved

Not exactly. You would want to specify VSS_VDD with setup_adc(), othwerwise AN13 is erroneously set to analog mode and RB13 I/O function disabled.
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