Friday, July 10, 2015

INTERFACING OF ATmega16 TO LCD AND SENDING DATA TO LCD VIA USART


Hi Guys Today we see how to transfer data from USART to LCD in ATmega16

Interfacing of LCD to ATmega16 and sending data to LCD from USART PORT

To design this Project we need to initialize USART and LCD

Then we must fetch data from TXD Pin send to LCD display.

To Enable USART:

In this we are using F_CPU = 8MHz; for the USART communication we should initialize proper Baud Rate.

To Enable USART:
    1.) Baud Rate should be set.
    2.) Initialize Control register for 8bit data transfer

We take Baud Rate as 9600























For F_cpu = 8Mhz and Baud Rate 9600 we should enter the value of UBRR value as shown in Table above i.e.: 51 in decimal so in we must enter 33 Hex Value.
U2X = 0 means asynchronous and U2X = 1 means synchronous.
We are using asynchronous transmission.
There are 3 control register and 1 data register for USART

Control Register:

1.) UCSRA
2.) UCSRB
3.) UCSRC

Data Register:

1.) UDR

Control Register:
        1.) UCSRB & UCSRC:

In this Register we should enable TXEN and RXEN bit by setting it 1(high).

And there is bit UCSZ2 bit with used to set whether it’s a 8 bit transmission or 9 bit transmission.

UCSZ2 combine with two other bit UCSZ1 and UCSZ0 in Register UCSRC are used to set it the Table show the setting.
We are using the Character Size as 8 bit, so UCSZ2-UCSZ0 = 011

In UCSRC Register there is bit URSEL which is used to access the UBRR Register and UCSRC Register if Set 0 means UBRR (initially its UBRR Register) and when set 1 we can use UCSRC Register. Thus to set 8bit transmission we should 1st set URSEL bit.

 


2.) UCSRA:

   U2X = 0 because we are using Asynchronous mode.(Initially it is 0)

3.) UDR:

This is a Data register for USART it convert Serial data (8 bit) into Parallel (8 bit) data and vice versa.
Is used to for transmitting and receiving the data from TXD and RXD Pin.


To Enable LCD:

1.)           We are using 4-bit LCD.

       To interface LCD in 4-bit mode we have seen in previous topic.
     For more details in coding LCD please refer Videos

In this program we receive each data from the rxd pin and send it to LCD using microcontroller.

Each time a data is send via serial port it will be displayed in LCD.



No comments:

Post a Comment