Page 1 of 1
LCD Problem
Posted: Sun Mar 26, 2006 12:54 pm
by Adan_T
Hi,
I have the LK204-25 LCD and I want to display a character (letter 'A') on it
but
I just get the screen full of black blocks. I am using the Atmega32 to send this
letter serially. I connected the UART TXD pin to the LCD input pin with a jumper
wire. I know it could be a contrast problem that could be solved using a pot.
Any suggestions as to how to solve
this
problem?
Thanks in advance.
Posted: Mon Mar 27, 2006 10:42 am
by Raquel
Hi Adan_T,
Thank you for posting on the forum.
Please check that the LK204-25 is set for TTL communications. It comes default to RS232 and this is probably why you can not talk to the display properly.
Best Regards
Posted: Mon Mar 27, 2006 3:57 pm
by Adan_T
Hi Raquel,
Could you please tell me how to do this.
Posted: Mon Mar 27, 2006 4:30 pm
by Raquel
Hi Adan_T,
I just checked the manual for the LK204-25 (I have a feeling that you have a PCB rev 1.23 - this number can be found on the PCB), unfortunately, it does not have easy access like the ones on the new PCB revisions. It will probably be easier if you connect an RS232 transceiver and then connect to the RX pin of the module.
It is possible to connect the TX (TTL levels) of your ATmega32 to the RX of the uC on board, but then you will have to do this at your OWN risk; if you are comfortable doing some soldering. I can give you the pin to solder to, but again, any damage that may be caused of this is not something we can cover.
By the way, how exactly do you connect the TX of the ATmega32 to the 'LCD input pin' as you mentioned?
Posted: Mon Mar 27, 2006 5:07 pm
by Adan_T
Hi Raquel,
I have four connections to my LK204-25 (four jumper wires)
- One goes from my Atmega32 UART TXD pin to pin 3 of the LK204-25
- Another jumper wire is used to connect pin 5 of LK204-25 to ground
- Third jumper wire is used to connect pin 1 of power connector to 5.14 Volts
- And the fourth one is used to connect pin 4 of power connector to ground
I'm not sure if I am setting the contrast command correctly. I wanted to send the commands like
it is done with the example on the manual but I haven't been able to find the Zcomm serial library
so I went ahead and did it like it is shown on my code. Is this correct?
Do you
have any suggestions for a simpler way to sending commands to the LK204-25?
BY THE WAY I CAN NOW SEE BLACK BOXES ON LINES 1 AND 3 ONLY
My code is the following:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
int txbuffer[32];
void USART_Transmit( unsigned char data);
void USART_Transmit_Contrast(int);
void delay_ms(unsigned short ms);
int main (void)
{
int light_screen =0;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 19200
UCSRA=0x02;
UCSRB=0x08;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
USART_Transmit_Contrast(light_screen); // set contrast
USART_Transmit('A' );
}
void USART_Transmit( unsigned char data)
{
// Wait for empty buffer
while ( !( UCSRA & (1<<UDRE)) )
;
// Put data into buffer, sends the data
UDR = data;
}
void USART_Transmit_Contrast(int white_screen)
//void Contrast(int white_screen)
{
while (1)
{
int i;
txbuffer[0] = '2';
txbuffer[1] = '5';
txbuffer[2] = '4';
txbuffer[3] = ' ';
txbuffer[4] = '8';
txbuffer[5] = '0';
txbuffer[6] = ' ';
txbuffer[7] = '[';
txbuffer[8] = 'white_screen';
txbuffer[9] = ']';
//txbuffer[10] = ';';
for ( i=0 ; i<10 ; i++ )
{
USART_Transmit(txbuffer);
delay_ms(500);
}
break;
};
}
void delay_ms(unsigned short ms)
{
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
Posted: Mon Mar 27, 2006 5:45 pm
by Raquel
Hi Adan_T,
Some questions / observations:
- what frequency are you running your uC?
- you are still talking to the display in RS232 levels, you need to talk in TTL
- command prefix is 254. it is not '2' '5' and '4', so when you send it, fill your array with txbuffer[0] = 254, then txbuffer[1] = 80, then txbuffer[2] = <value from 0 to 255>
- you have a while (1) in USART_Transmit_Contrast, is this what you really want?
- your connections sound good, provided you have RS232 trasceiver, but you do not seem to have this, so again, if you are willing to do some soldering, i can tell you the pin
- looking at the ATmega32 data sheet, you do not really need to write UCSRC anything, leave it as is
Posted: Mon Mar 27, 2006 6:03 pm
by Adan_T
Hello again,
Yes, I'm willing to do some soldering, please tell me which pin.
The uC is running at 8 MHz.
I'll change the while (1) loop to a for loop and modify the txbuffer
Could you elaborate a little more as to how to talk to the LK204-25 in TTL level
Thank you for your help