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 CCS Technical Support

16F88 and ADC

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



Joined: 16 Jul 2008
Posts: 50

View user's profile Send private message

16F88 and ADC
PostPosted: Thu Aug 07, 2008 6:14 pm     Reply with quote

Hi again, im trying to use the ADC of 16F88...
If I connect (completly turn my POT) to the "positive side" it reads well...
But if I decrease the POT strange characters start apearing :/

CODE:
Code:
#include <16F88.h>
#device adc=10

#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=4000000)

#include "flex_lcd.c"

long int q;
float p;
void main()
{
   
   setup_adc( ADC_CLOCK_DIV_64 );
   setup_adc_ports(sAN0);
   set_adc_channel( 0 ); // AN0
   
   lcd_init();
   while(1)
   {
      q = read_adc();
      p = 5.0 * q / 1024.0;
      printf(lcd_putc, "\fADC = %4ld\nVoltage = %01.2fV", q, p);
      delay_ms(200);
   }
}


Connections:
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7

#define LCD_RS PIN_B1
#define LCD_RW PIN_B2
#define LCD_E PIN_B3
//#define USE_LCD_RW 1

CCS Version: 4.074
JDM Programmer
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