View previous topic :: View next topic |
Author |
Message |
kein
Joined: 23 Jul 2007 Posts: 103
|
adc pic16f877a not has stopped working! |
Posted: Fri Sep 07, 2007 8:10 am |
|
|
The following codes prints zero even when Vref+ is set to vdd(5v) and vref- set to ground(vss). why isn't it working? any idea?
Thanks
Code: | #include <16F877A.h>
#device *=16
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <KBD.C>
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include "LCD.c"
void main()
{
long int adcValue; // 16-bit storage for ADC reading
lcd_init();
setup_adc_ports(AN0_AN1_AN4_AN5_VREF_VREF);
setup_adc(ADC_CLOCK_DIV_32);;
setup_adc(ADC_OFF);
lcd_goto_xy(1,1); // Type some characters and backspace over them.
lcd_put_c(" X Y Z");
delay_Ms(1000);
// TODO: USER CODE!!
while(1)
{
//AccelCalibrateXYZ();
set_adc_channel(0); // select the required channel
delay_us(10);
adcValue =read_adc();
lcd_gotoxy(13,2);
printf(lcd_putc, "%Lu ", adcValue);
delay_ms(200);
}
//return 0;
} |
|
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Fri Sep 07, 2007 8:23 am |
|
|
try commenting out the following line in your code: Code: | setup_adc(ADC_OFF); |
That might solve your problem |
|
|
kein
Joined: 23 Jul 2007 Posts: 103
|
it did solve the problem |
Posted: Fri Sep 07, 2007 9:57 am |
|
|
it did solve the problem; thanks |
|
|
|