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

setup_adc divide by 64?

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







setup_adc divide by 64?
PostPosted: Mon Jul 03, 2006 9:48 am     Reply with quote

Hi there,
Using the 16F877A device, by setting the correct bit-pattern in ADCON0 & ADCON1, apparently the ADC conversion-time can be set to Fosc/64.
The header file does not have a define for Fosc/64 as the parameter in setup_adc, anybody know what the value for this is?
Cheers,
Phil
Ttelmah
Guest







PostPosted: Mon Jul 03, 2006 10:15 am     Reply with quote

It should be in the header file. What compiler version have you got?. In 3.249, it is there as ADC_CLOCK_DIV_64. It is there back in 3.221. However it is missing in 3.191.

If your compiler is this old, there may well be other problems. The definition format was changed for the latter compilers, to give access to the extra bit needed for this (the old setup, only adjusted ADCS1, and ADCS0). Try:
#define ADCS2ON 0x40

Then
SETUP_ADC_PORTS(ALL_ANALOG | ADCS2ON);

Change the 'ALL_ANALOG' selection, to whatever one you need to select your required analog inputs, and then use:

SETUP_ADC(ADC_CLOCK_DIV_32);

Basically the pattern needed, is the same in the port controlled by 'setup_adc', as required for /32, but needs the extra bit set in the ADCON1, to select /64. ADCON1, is the port used to set which inputs are enabled, and the extra bit corresponds to the '0x40' pattern defined above. If this doesn't work, you'll have to go 'manual', and control the ports yourself.

Best Wishes
Phil_P
Guest







Re:ADC Clock Divide by 64
PostPosted: Tue Jul 04, 2006 2:45 am     Reply with quote

I think I have quite an old compiler, but thanks for this advice - makes sense and should work!!
Thank you :-)
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