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

adc pic16f877a not has stopped working!

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



Joined: 23 Jul 2007
Posts: 103

View user's profile Send private message

adc pic16f877a not has stopped working!
PostPosted: Fri Sep 07, 2007 8:10 am     Reply with quote

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

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

PostPosted: Fri Sep 07, 2007 8:23 am     Reply with quote

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

View user's profile Send private message

it did solve the problem
PostPosted: Fri Sep 07, 2007 9:57 am     Reply with quote

it did solve the problem; thanks
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