TTL communications
Posted: Tue Mar 28, 2006 1:43 pm
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--;
}
}
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--;
}
}