View previous topic :: View next topic |
Author |
Message |
madhura027
Joined: 27 May 2015 Posts: 8
|
what does it mean? |
Posted: Wed Jun 03, 2015 4:10 am |
|
|
what does it mean?
1.#device ADC=10 (or 8) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19500
|
|
Posted: Wed Jun 03, 2015 4:26 am |
|
|
Read the manual.....
(under #device)
"ADC=x
Where x is the number of bits read_adc() should return
"
Key is if you want to only use the ADC as 8bits (so the value can be stored in an int), or want it's full accuracy (may be =12 or even =14 for some ADC's). |
|
|
madhura027
Joined: 27 May 2015 Posts: 8
|
|
Posted: Wed Jun 03, 2015 4:41 am |
|
|
THanks . also
in adc what is difference between the adc program when programming using adc registers like adcon and when using the program like setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);
set_adc_channel(0); |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Wed Jun 03, 2015 4:58 am |
|
|
You need to read and study the Microchip datasheet for your PIC. There's an entire section just for the ADC peripheral. All PICs that have an ADC peripheral are very similar in operation though newer ones have more features once you understand the basics then you'll know how they work.
The CCS ADC functions just setup/control the various bits of the registers associated with the ADC.
ie:
set_adc_channel(0);
is the CCS function that sets the analog mux in front of the ADC converter to channel 0 (zero). This means that every reading of the ADC will be from that pin.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19500
|
|
Posted: Wed Jun 03, 2015 5:13 am |
|
|
The key differences between using the CCS functions, and writing directly to the registers, is that the bit patterns needed are coded for you, and use names that make them much easier to understand. It is appallingly easy to write the wrong values to the registers.
Hopefully you are _not_ using ADC_CLOCK_INTERNAL, unless your chip is running under 1MHz.....
Read the data sheet. For 99% of PIC's, the internal clock is only recommended if you are running below 1Mhz, or if you are putting the chip to sleep to read the ADC..... |
|
|
|