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

dsPIC33EP64GS502 ADC [SOLVED]

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



Joined: 19 Feb 2017
Posts: 4

View user's profile Send private message

dsPIC33EP64GS502 ADC [SOLVED]
PostPosted: Tue Aug 29, 2017 2:47 pm     Reply with quote

Hello!

I'm trying to read the dsPIC ADC pin (an0), but if I try the following code the microcontroller freezes:

Initialization:
Code:
setup_adc(ADC_CLOCK_SYSTEM);
setup_adc_ports(sAN0);


ADC Read:
Code:
set_adc_channel(1);
vetor_ad1[0] = read_adc();


Reading the dsPIC33EP512GS502 datasheet I found that this device has a "dedicated ADC Module"...

How I can use this module?

Compiler Version 5.074
_________________
Ricardo


Last edited by RicSToz87 on Wed Aug 30, 2017 7:45 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Aug 30, 2017 12:00 am     Reply with quote

You need to look at ex_adc_epgs.c
This is the example of using the ADC on this type of chip.
There are several more things that have to be setup, than simply the master clock....

You also need to study the data sheet about which ADC accesses which input pin. You channel selection would be wrong even without the dedicated ADC (AN0 != channel 1....).
RicSToz87



Joined: 19 Feb 2017
Posts: 4

View user's profile Send private message

[SOLVED]
PostPosted: Wed Aug 30, 2017 6:54 am     Reply with quote

Ttelmah wrote:
You need to look at ex_adc_epgs.c
This is the example of using the ADC on this type of chip.
There are several more things that have to be setup, than simply the master clock....

You also need to study the data sheet about which ADC accesses which input pin. You channel selection would be wrong even without the dedicated ADC (AN0 != channel 1....).


Thanks, Ttelmah!

Works fine as the example!
_________________
Ricardo
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Aug 30, 2017 7:02 am     Reply with quote

Good. Smile
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