Академический Документы
Профессиональный Документы
Культура Документы
ADMINISTRATIONS
Avoid
Obstacles
UART
UART: Universal Asynchronous Receiver Transmitter
Two
wires: Rx, Tx
Full duplex
Asynchronous
do they communicate??
Rx
Tx
Tx
Rx
second)
9600
UART
9600 Baudrate
generator
Baudrate: 9600
bps
Length of a bit =
1/9600 (seconds)
UART DATA
7 or 8 bits data
One or two stop bit
Even parity: If the data has odd number of 1, parity bit = 1 (make
it even); else parity bit = 0
Odd parity: If the data has even number of 1, parity bit = 1 (make
it odd); else parity bit = 0
APPLICATIONS
RS232 IC
USB
UART
MSP43
0
Todays
Labs
COM PORT
Other
Sensors
PC or
other
systems
USB
serial
IC
(FT232)
Other
systems
RS485 IC
RS485 IC
USART
and USART1
Universal
Synchronous/Asynchronous Receive
Transmit
The USART0 module support 3 protocols
UART
SPI
I2C
The
UART
SPI
SPI
pins
UART pins
I2C pins
Taroko Schematic
FT232
USB
serial
IC
UART
I2C
Expansion
Connector
(U2)
PC
SP
I
CC2420
Radio IC
UART MODE
Character Format
Tx
Rx
Tx
Rx
Tx
Rx
Rx
Tx
Rx
Tx
Two devices
Seldom use,
we wouldnt
talk about it
For
multiprocessor
format, not use
Usually we use
8-bit data
Receive
Transmit
Set URXEx= 1 to
enable the
receiver
Set UTXEx= 1 to
enable the
transmitter
When data is
written to the
transmit buffer
(UxTXBUF), a
transmission start
UART Clock
Source
32768 Hz
(ACLK)
Desire baud
rate
For Example:
UART Clock Source =
32768
Desire baud rate = 2400
Divider = 32768/2400 =
Fractional
13.653
part
UxBR = 13,
=
0.653
Divide
r
The equation
Integer
part
MODULATIONS
Bit
7
UxMCTL 0 1 1 0 1 0 1 1
m7
m6
m5
m4
m3 m2
m10
m1 m0
m9 m8
1 n 1
mi 0.653
n i 0
For Example:
UART Clock Source =
32768
Desire baud rate = 2400
Divider = 32768/2400 =
13.653
UxBR = 13,
=
0.653
You knowthe
0.653 n 7 of mi should be 7
msummation
n 1
But
i 0
For
UxMCTL
Bit
0 1 1 0 1 0 1 01
Bit
7
m4
m3 m2
m10
m1 m0
m9 m8
EXAMPLE
n 1
m
i 0
Bit
0
Bit
7
0 1 1 0 1 0 1 1
m0
m8
m1
m9
m2 m3
m10
m4
Useful resource!!!
m5
m6
m7
0.653 n 7
Bit
0
Bit
7
1 0 1 1 0 1 0 1
m0
m8
http://mspgcc.sourceforge.net/baudrate.html
m1
m9
m2 m3
m10
m4
m5
m6
m7
UART INTERRUPTS
Transmission interrupt
Reception interrupt
To
Two ways to do
By a while loop
By Interrupt
1.Enable transmit interrupt
2.When it is ready to transmit
another byte, it will generate
an interrupt request
3.Transmit next byte in the
ISR
Program will
branch to the ISR,
need extra CPU
cycles
UXCTL
UXTCTL
Select
clock
source
If you want to
disable the
transmitter, wait
until this bit is set
to 1
UXRCTL
Error Detection
Framing
error
Parity
error
Overrun
error
Break
detect
OTHER REGISTERS
and UxTXBUF
For UART0
For UART1
INTERRUPT REGISTERS
Interrupt
flag registers
For UART0
For UART0
For UART1
For UART1
INITIALIZATION/RECONFIGURATION UART
Set SWRST
Initialize all UART registers when SWRST=1
Enable UART module (ME1 or ME2)
Clear SWRST (SWRST=0)
Enable interrupts (optional)
SET DCO
Capture at every
raising edge
Capture_
1
Capture
source
Timer Clock source
Counter increase at
every raising edge
Hz
If Capture_1 = 3000
Capture_2 = 3250
Freq. of DCO = (3250 3000) * 4096 =
1024000 Hz
TODAYS LABS
You dont have to write the routine by yourself, use the sample code
on course webpage (sample code form TI)
The routine sets the ACLK to 32768/8 = 4096 Hz
It use a variable DELTA to set the frequency of DCO
DONT set the DCO too high or too low (check datasheet)
If DCO = 1000000 Hz
i = 125000
The LED should flash approximately
every second
Set DCO
LAB 2: SEND TO PC
Use the sample file on course webpage
Setting UART registers
UART setting
Baudrate
A5 53 54 41 52 54 0D 0A
5A A5 53 4C 45 45 50 0D 0A
UART setting
Baudrate
http://www.ftdichip.com/Drivers/CDM/CDM%202.02.04.exe
Install driver
Device
manager
TERMINAL PROGRAM
Realterm
http://realterm.sourceforge.net/
http://sourceforge.net/project/showfiles.php?group_id=67297
Enter
baud rate
Enter
COM
port
REALTERM
Displa
y
format
REALTERM
UART
setting
REALTERM
Capture data
to a file
REALTERM
Send out
data