PDA

View Full Version : ADC_Clock Vs ADCON0



locko
- 11th August 2007, 22:18
Hi,

Just trying to get to grips with my first project using ADC using a 16F73 and have a quick couple of questions.
After looking at other code examples on this forum and reading the datasheet my question is.... is there any point using a define adc_clock 2 and a adcono =%10000001? From what I can understand the adcono will set my clock speed bits to %10(2) anyway.
What is the correct way to use these two statments?

'Includes
INCLUDE "modedefs.bas"

'Definitions
define OSC 20
DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 100

'Initialize chip and Ports
ADCON1 = %00000100
ADCON0 = %10000001

Thank you :)

Acetronics2
- 13th August 2007, 14:45
Hi, Locko

You just define twice your ADC clock frequency ...

DEFINE is just needed if you use the PbP ADCIN Statement ... which cares about ALL others ADCON0 Bits !!!

See PbP "Samples" section ( on the CD ...) for further explanations.

Alain

Bruce
- 13th August 2007, 14:47
If you're using ADCIN, then TRIS and ADCON1 are the only registers you need to mess with.
PBP knows the clock setting from DEFINE ADC_CLOCK ? and handles ADCON0 for you.

locko
- 13th August 2007, 18:32
Thanks for the replies guys,

I thought it was doubling up on the settings. I was going to use the adcin command so will drop the adcon0 from my prog. as well as check out the samples on the cd.

Is that the same for most PBP commands, can I forget about setting the registers manually?

Regards,

Paul

Bruce
- 16th August 2007, 15:09
Is that the same for most PBP commands, can I forget about setting the registers manually?
No. There are still some registers you'll want to configure manually. Depending on the PIC
and command. Pretty much everything is covered in the manual for each command, but if
you have questions, post them here.