View previous topic :: View next topic |
Author |
Message |
Salenko
Joined: 08 Sep 2008 Posts: 84
|
using portA with flex_lcd |
Posted: Wed Sep 10, 2008 12:38 pm |
|
|
Hi all,
can anybody tell me why I failed to use the PortA to drive the LCD (using flex_lcd.c driver)?
-this is my main progam:
Code: | #include <16F876.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#include "flex_lcd.c"
//==========================
void main()
{
byte byte_b;
//T0CS = 0
set_tris_a(0);
set_tris_b(0xff);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
while(1)
{
byte_b=input_b();
if (byte_b==0x01) // start the LCD with a push-botton connected to RB0
{
lcd_init(); // Always call this first.
lcd_putc("\fHello World\n");
lcd_putc("Line 2.");
}
}
} |
changes in flex_lcd.c:
(I only changed the pins to fit my board and commented out #define USE_LCD_RW 1 as written in the comments.
Code: | // flex_lcd.c
// These pins are for the Microchip PicDem2-Plus board,
// which is what I used to test the driver. Change these
// pins to fit your own board.
#define LCD_DB4 PIN_A0
#define LCD_DB5 PIN_A2
#define LCD_DB6 PIN_A4
#define LCD_DB7 PIN_A5
#define LCD_E PIN_A1
#define LCD_RS PIN_A3
//#define LCD_RW PIN_A2
// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.
//#define USE_LCD_RW 1 |
this is a printscreen from the simulation (before activating the LCD)
printscreen when the LCD is activated (but no display !- notice the changements in portA pins)
thanks for any kind of help.
Rq :I have read the I/O section of the 16F876 datasheet before asking |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 10, 2008 12:54 pm |
|
|
The contrast pin on the LCD is not connected to anything.
Try connecting it to 0.45v with a voltage divider created with
a 10K and a 1K resistor. Or, maybe just connect it to ground.
You're doing all this in a simulator anyway. Maybe it will
accept ground as a "correct" Vee voltage on the LCD.
(Read the spec on the LCD for the simulator). |
|
|
meereck
Joined: 09 Nov 2006 Posts: 173
|
|
Posted: Wed Sep 10, 2008 3:47 pm |
|
|
why is RA4 connected to ground on the left side of the scheme?
The external pull-up doesnt work because there is ground all the time |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Thu Sep 11, 2008 5:41 am |
|
|
meereck wrote: | why is RA4 connected to ground on the left side of the scheme?
The external pull-up doesnt work because there is ground all the time |
oooh, you're right !!
well now, it running , thank you !!
Last edited by Salenko on Thu Sep 11, 2008 5:44 am; edited 1 time in total |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Thu Sep 11, 2008 5:43 am |
|
|
PCM programmer wrote: | The contrast pin on the LCD is not connected to anything.
Try connecting it to 0.45v with a voltage divider created with
a 10K and a 1K resistor. Or, maybe just connect it to ground.
You're doing all this in a simulator anyway. Maybe it will
accept ground as a "correct" Vee voltage on the LCD.
(Read the spec on the LCD for the simulator). |
www.brokerscreen.com/manufacture/HITACH/pn/LM016L.htm
thank you. |
|
|
meereck
Joined: 09 Nov 2006 Posts: 173
|
|
Posted: Thu Sep 11, 2008 3:35 pm |
|
|
glad that it works now.
regards |
|
|
|