View previous topic :: View next topic |
Author |
Message |
Dave200 Guest
|
ADC setup |
Posted: Thu Apr 03, 2008 1:08 am |
|
|
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
|
|
Posted: Thu Apr 03, 2008 1:41 am |
|
|
And by looking at the chip datasheet...
Is it possible to do?
Matro. |
|
|
Matro Guest
|
|
Posted: Thu Apr 03, 2008 1:46 am |
|
|
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
|
|
Posted: Thu Apr 03, 2008 10:21 am |
|
|
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 |
|
|
|