![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Francesc Guest
|
A/D from 16F873 |
Posted: Thu Feb 12, 2004 12:17 am |
|
|
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();
}
} |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 12, 2004 1:10 am |
|
|
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] |
|
![](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
|