![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
16f873 10 bits adc |
Posted: Sun Apr 20, 2003 12:55 pm |
|
|
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) |
|
![](templates/subSilver/images/spacer.gif) |
R.J.Hamlett Guest
|
Re: 16f873 10 bits adc |
Posted: Sun Apr 20, 2003 1:39 pm |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
Calamar
Joined: 07 Sep 2003 Posts: 60 Location: Buenos Aires (Argentina)
|
Re: 16f873 10 bits adc |
Posted: Sun Apr 20, 2003 5:35 pm |
|
|
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) |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|