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 with LCD

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



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

ADC with LCD
PostPosted: Wed Aug 25, 2004 9:15 pm     Reply with quote

I write a routine to display the result of ADC channel 0 on the LCD.
I have the PIC Demo 2 Plus board, I have the LCD working fine with the
previous posted about the KEYPAD on port_b. But when I use it on the adc experiment,
the ADC part is working fine, but the display (result) is too fickering.
Is it the problem cause by some kind of timer delay of the adc?
Here is my code:

I welcome any suggestions.

Thanks.


Code:

#include <18f458.h>
#device ADC=10
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) 
#include <lcdd.c>

void main()
{

   int16 value;
   int realValue;

   setup_port_a( RA0_ANALOG );
   setup_adc( ADC_CLOCK_INTERNAL );
   while(1)
   {
      lcd_init();   
      set_adc_channel( 0 );
         delay_us(25);
      value = read_adc();
         printf(lcd_putc,"\fADC Value: %ld",value);
    }
}
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

LCD Flicker
PostPosted: Wed Aug 25, 2004 10:45 pm     Reply with quote

You are reinitializing the LCD display every time you execute the while loop. Move the lcd_init() up, outside of the loop, to right after the ADC setup line.

BTW. do you really want to update the LCD display 50-100 times a second?

You might want to put a delay_ms(250) or something similar after the printf() statement to slow things down in the while loop just a bit. Updating it at that rate could cause potential timing problems depending on the type of display you are using.
cxiong



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

PostPosted: Thu Aug 26, 2004 6:49 am     Reply with quote

That's it.

Thanx...
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