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

A/D from 16F873

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







A/D from 16F873
PostPosted: Thu Feb 12, 2004 12:17 am     Reply with quote

Question
Hi all, is very strange, we try to read 4 ports analogs from 16F873, but the readings not are corrects.
We try to enter differents voltages, here a sample:
0,0 V..0000 bit
1,0 V..0190 bit
2,0 V..0177 bit
3,0 V..0121 bit
4,0 v..0079 bit
4,5 v..0181 bit
5,0 v..1023 BIT

We include an small part of my code to try found the error.
The compiler version is 2.732 #10544.
Please, help ..

#include <16f873.h>
#device ADC=10
#fuses xt,nowdt,put,nolvp
#use delay(clock=4000000)
#use RS232(BAUD=9600,BITS=8,XMIT=PIN_C6,RCV=PIN_C7)
#bit ADFM_BIT=0x9F.7
LONG T,K1,K2,K3,K4,K;
main()
{
SETUP_ADC_PORTS(A_ANALOG);
//SETUP_ADC(ADC_CLOCK_DIV_8);
SETUP_ADC(ADC_CLOCK_INTERNAL);
ADFM_BIT=1;
while(1)
{
SET_ADC_CHANNEL(0);
delay_ms(10);
T=READ_ADC();
delay_ms(50);

SET_ADC_CHANNEL(1);
delay_ms(10);
T=READ_ADC();
delay_ms(50);

SET_ADC_CHANNEL(2);
delay_ms(10);
T=READ_ADC();
delay_ms(50);

SET_ADC_CHANNEL(5);
delay_ms(10);
T=READ_ADC();
delay_ms(50);
void display();
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 12, 2004 1:10 am     Reply with quote

Quote:
Hi all, is very strange, we try to read 4 ports analogs from 16F873, but the readings not are corrects.

SET_ADC_CHANNEL(5);
delay_ms(10);
T=READ_ADC();
delay_ms(50);
void display();


In section 11 of the 16F87x data sheet, there is a chart with this title:
PCFG3:PCFG0: A/D Port Configuration Control bits
The top of the chart has these column headings:
AN7 (1) AN6 (1) AN5 (1) AN4 AN3 AN2 AN1 AN0

Below the chart is this note:

Note 1: These channels are not available on PIC16F873/876 devices.


[/u]
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