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 setup

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







ADC setup
PostPosted: Thu Apr 03, 2008 1:08 am     Reply with quote

All,

I've just picked up the CCS complier, after using an alternative.

However i am trying to setup A0 and A1 to be ADC pins, and want the rest of PORTA to be STD I/O pins.

Is this possible? looking at the function calls, i cant see a way of doing it.

Thanks and regards

Dave.
Matro
Guest







PostPosted: Thu Apr 03, 2008 1:41 am     Reply with quote

And by looking at the chip datasheet...
Is it possible to do?

Matro.
Matro
Guest







PostPosted: Thu Apr 03, 2008 1:46 am     Reply with quote

Have a look at the help of "setup_adc_ports()" function.
If you have PCW you can use the wizard to see what are the possible combinations.

Matro.
w2drz



Joined: 27 Dec 2006
Posts: 55
Location: Western New York - USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Apr 03, 2008 10:21 am     Reply with quote

Hi,
First time is very confusing on set ADC for use.

As normal read the chip PDF spec's completely,
no short cuts as that leads to lack of knowledge on chip use.

Now to help you on starting to understand what is needed.

After reading the chip PDF then go to the compiler "DEVICES" folder in
c:/program files/picc/ devices.

look up the chip number "xxxxxxxxxx.h"
This will show CCS compiler settings for the chip you have selected to use.

Now I will show a sample to start you, then you need to learn the rest.
examples follow to consider for you to learn how to do your self.

header setup

//#device ADC=16 // to allow if chip is upgraded to a 16 bit ADC, CCS & microchip allows this to be use for chip upgrades in the ADC module
//#device ADC=10 // normal CHIP ADC 10 bit
//#device ADC=8 // if wish for only 8 bit ADC

//simple setup in main, SEE: device.h file for correct setting info

SETUP_ADC_PORTS (0),(1);
setup_adc (ADC_CLOCK_DIV_16);

// _DIV_16 setting depends on clock speed, read CCS manual, device.h and chip .PDF to understand the correct clock speed and DIV setting for ADC.

Hope this helps your understanding how to start learning.


tom
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