View previous topic :: View next topic |
Author |
Message |
cxiong
Joined: 09 Sep 2003 Posts: 52
|
ADC with LCD |
Posted: Wed Aug 25, 2004 9:15 pm |
|
|
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: 1934 Location: Norman, OK
|
LCD Flicker |
Posted: Wed Aug 25, 2004 10:45 pm |
|
|
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
|
|
Posted: Thu Aug 26, 2004 6:49 am |
|
|
That's it.
Thanx... |
|
|
|