Escolar Documentos
Profissional Documentos
Cultura Documentos
Prepared by:
Eng. Ashraf Darwish
Ashraf.emad.darwish@gmail.com
Session 6
USART
Introduction
Introduction
To be able to deal with USART you must know:
Introduction
Data transmission techniques can be :
serial
paralle
l
Long
distance and
low noise
Less wires
High speed
More wires
and high
noise
Methods of
communication
1-synchronous:
In
The
2-Asynchronous:
Single
It
No
common clock.
Ways of communication:
TTL vs RS232
Logic 1
Logic zero
Usage
TTL
RS 232
5V
0V
Digital IC
( microcontroller)
-3V to -25V
+3V to +25V
Computers
TTL vs RS 232
TTL vs RS 232
TTL vs RS 232
Male Socket:
Baud rate
Baud rate
one).
Baud rate
Parity Bit
Odd
1s
Even 1 s
parity bit is 1.
parity bit is 0.
Registers
1-USART Control and Status Register A
(UCSRA).
2-USART I/O Data Register (UDR).
3-USART Control and Status Register B
(UCSRB).
Registers
1-USART Control and Status Register A (UCSRA).
Bit
Bit
Bit
Bit
Bit
Bit
7
6
5
4
3
2
Registers
2-USART I/O Data Register (UDR).
The
Registers
3-USART Control and Status Register B (UCSRB).
Hyper Terminal
Hyper Terminal
Hyper Terminal
Hyper Terminal
Coding
Coding
#include <mega16.h>
#include <stdio.h>
void main(void)
{
char temp;
DDRA=0x00;
PORTA=0x00;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop,
No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
while (1)
{
if(PINA.1==1){printf("Enter
password:");
scanf("%c",&temp);
if (temp==65){printf("
Welcome USER");
temp=0;}
else {printf(" wrong password
");}}
};
}
`
Thank you
Contact:
http://www.facebook.com/groups/263197427113025
/
Ashraf.darwish@ymail.com
Ashraf.emad.darwish@gmail.com
+201064897791