Hi,
I have the LK204-25 LCD REV1.23. I have made the modifications shown on
this link
http://www.lcdforums.com/forums/viewtop ... =ttl#15824
to talk to my Atmega32 in TTL level and be able to set the LCD contrast and display letter 'A' on the LCD
The uC is running at 8 MHz.
I have the following connections:
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
Thank you for your help
The code is the following:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
char 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 = 39;
int light_on = 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)
{
int i;
txbuffer[0] = 254;
txbuffer[1] = 80;
txbuffer[2] = white_screen;
for (i=0; i<3; i++)
{
USART_Transmit(txbuffer);
delay_ms(500);
}
}
void delay_ms(unsigned short ms)
{
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
TTL communications
Hello Raquel,
I forgot to mention in my previous post that my LCD is not working yet.
What happens now is
that I download my code to the Atmega32 while I have all the preiously metioned
connections in place, but nothing happens. The screen shows the Matrix Orbital logo.
Do you have any suggestions as to what the problem could be?
By the way
I'm still running my Atmega32 at 8MHz
Regards
I have modified the code a little bit:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
char txbuffer[5];
void USART_Transmit( unsigned char data);
void USART_Transmit_Contrast(int);
void USART_Transmit_Backlight_on(int);
void USART_Transmit_Clear_Screen(void);
void delay_ms(unsigned short ms);
int main (void)
{
int light_screen = 0;
int light_on = 0;
char letter = 'A';
// 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_Backlight_on(light_on);
USART_Transmit_Clear_Screen();
USART_Transmit(letter);
}
void USART_Transmit_Contrast(int white_screen)
{
int i;
txbuffer[0] = 254;
txbuffer[1] = 80;
txbuffer[2] = white_screen;
for (i=0; i<3; i++)
{
USART_Transmit(txbuffer);
delay_ms(100);
}
}
void USART_Transmit_Backlight_on(int permanently)
{
int j;
txbuffer[0] = 254;
txbuffer[1] = 66;
txbuffer[2] = permanently;
for (j=0; j<3; j++)
{
USART_Transmit(txbuffer[j]);
delay_ms(100);
}
}
void USART_Transmit_Clear_Screen(void)
{
int x;
txbuffer[0] = 254;
txbuffer[1] = 88;
for (x=0; x<2; x++)
{
USART_Transmit(txbuffer[x]);
delay_ms(100);
}
}
void USART_Transmit( unsigned char data)
{
// Wait for empty buffer
while ( !( UCSRA & (1<<UDRE)) )
;
// Put data into buffer, sends the data
UDR = data;
}
void delay_ms(unsigned short ms)
{
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
I forgot to mention in my previous post that my LCD is not working yet.
What happens now is
that I download my code to the Atmega32 while I have all the preiously metioned
connections in place, but nothing happens. The screen shows the Matrix Orbital logo.
Do you have any suggestions as to what the problem could be?
By the way
I'm still running my Atmega32 at 8MHz
Regards
I have modified the code a little bit:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
char txbuffer[5];
void USART_Transmit( unsigned char data);
void USART_Transmit_Contrast(int);
void USART_Transmit_Backlight_on(int);
void USART_Transmit_Clear_Screen(void);
void delay_ms(unsigned short ms);
int main (void)
{
int light_screen = 0;
int light_on = 0;
char letter = 'A';
// 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_Backlight_on(light_on);
USART_Transmit_Clear_Screen();
USART_Transmit(letter);
}
void USART_Transmit_Contrast(int white_screen)
{
int i;
txbuffer[0] = 254;
txbuffer[1] = 80;
txbuffer[2] = white_screen;
for (i=0; i<3; i++)
{
USART_Transmit(txbuffer);
delay_ms(100);
}
}
void USART_Transmit_Backlight_on(int permanently)
{
int j;
txbuffer[0] = 254;
txbuffer[1] = 66;
txbuffer[2] = permanently;
for (j=0; j<3; j++)
{
USART_Transmit(txbuffer[j]);
delay_ms(100);
}
}
void USART_Transmit_Clear_Screen(void)
{
int x;
txbuffer[0] = 254;
txbuffer[1] = 88;
for (x=0; x<2; x++)
{
USART_Transmit(txbuffer[x]);
delay_ms(100);
}
}
void USART_Transmit( unsigned char data)
{
// Wait for empty buffer
while ( !( UCSRA & (1<<UDRE)) )
;
// Put data into buffer, sends the data
UDR = data;
}
void delay_ms(unsigned short ms)
{
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
Hi Adan_T,
Sorry, I was looking at the post and all really that caught my eyes was "Thank you for the help". Now that I am looking at it again
.. So you have followed the traces to be cut and solder pads to be jumped in the LK204-25TTL.jpg in the link you mentioned?
Code looks good. Can you please try declaring unsigned char txbuffer[].
Also, in main, send 'A' only for now, and skip the other commands.
Please let me know how it turns out.
Sorry, I was looking at the post and all really that caught my eyes was "Thank you for the help". Now that I am looking at it again

Code looks good. Can you please try declaring unsigned char txbuffer[].
Also, in main, send 'A' only for now, and skip the other commands.
Please let me know how it turns out.
Raquel Malinis
Design and Development
Matrix Orbital
Design and Development
Matrix Orbital