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

16f873 10 bits adc

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



Joined: 07 Sep 2003
Posts: 60
Location: Buenos Aires (Argentina)

View user's profile Send private message Send e-mail MSN Messenger

16f873 10 bits adc
PostPosted: Sun Apr 20, 2003 12:55 pm     Reply with quote

Could someone help me?
I cant get 10 bits resolution, the next code
give me a error when I try compile it:

PRINTF FORMAT TYPE IS INVALID,



#include <16f873.h>
#use delay (clock=4000000)
#fuses NOPROTECT, XT, NOWDT, PUT, NOLVP, BROWNOUT
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7 )
byte seconds=0;
byte count=15;
byte mem=0;

#int_rtcc

clock_isr() {

if(count--==0) {
++seconds;
count=15;
}
}

main() {
setup_adc_ports ( RA0_ANALOG );
setup_adc ( ADC_CLOCK_INTERNAL );
set_adc_channel(0);


set_rtcc(0);

setup_counters (RTCC_INTERNAL, RTCC_DIV_256);
enable_interrupts (INT_RTCC);
enable_interrupts(GLOBAL);
do {
if(seconds!=mem) {
printf ("\n\r \%lu",read_adc());
mem=seconds;
}

} while(1);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 13834
_________________
Best Regards
Daniel H. Sagarra
La Plata (Argentina)
R.J.Hamlett
Guest







Re: 16f873 10 bits adc
PostPosted: Sun Apr 20, 2003 1:39 pm     Reply with quote

:=Could someone help me?
:=I cant get 10 bits resolution, the next code
:=give me a error when I try compile it:
:=
:=PRINTF FORMAT TYPE IS INVALID,
:=
:=
:=
:=#include <16f873.h>
:=#use delay (clock=4000000)
:=#fuses NOPROTECT, XT, NOWDT, PUT, NOLVP, BROWNOUT
:=#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7 )
:=byte seconds=0;
:=byte count=15;
:=byte mem=0;
:=
:=#int_rtcc
:=
:=clock_isr() {
:=
:= if(count--==0) {
:= ++seconds;
:= count=15;
:= }
:=}
:=
:=main() {
:= setup_adc_ports ( RA0_ANALOG );
:= setup_adc ( ADC_CLOCK_INTERNAL );
:= set_adc_channel(0);
:=
:=
:= set_rtcc(0);
:=
:= setup_counters (RTCC_INTERNAL, RTCC_DIV_256);
:= enable_interrupts (INT_RTCC);
:= enable_interrupts(GLOBAL);
:= do {
:= if(seconds!=mem) {
:= printf ("\n\r \%lu",read_adc());
:= mem=seconds;
:= }
:=
:= } while(1);
:=}
Add the following line, after the include file.
#DEVICE ADC=10

This switches the compiler to returning a 10 bit value. Without this, 'read_adc' will return an 8 bit value.
This is in the manual entry for the read_adc function.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13835
Calamar



Joined: 07 Sep 2003
Posts: 60
Location: Buenos Aires (Argentina)

View user's profile Send private message Send e-mail MSN Messenger

Re: 16f873 10 bits adc
PostPosted: Sun Apr 20, 2003 5:35 pm     Reply with quote

Thanx you a lot,,, it work perfectly


best regards
___________________________
This message was ported from CCS's old forum
Original Post ID: 13845
_________________
Best Regards
Daniel H. Sagarra
La Plata (Argentina)
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