ppt

advertisement
UART - Serial communic.
MS_uC / dnd / V08
4- 1
Programming Microcontroller
UART – Universal Asynchronous Receiver Transmitter
2007
ARM966
CORE
E
w/DSP
96 MHz
DMA
PFQ
BC
INTR
Cntl
CLK
Cntl
LVD
BOD
PLL
ADC
RTC
64K or 96K
Byte SRAM
256K or 512K
Byte Burst Flash
32K Byte
Burst Flash
JTAG ETM9 OTP
Mem
TIM
SPI
STR912FW44
I2C
Enet
MAC
USB
2.0FS
CAN
2.0B
GPIO
EXT.
Bus
UART
UART - Serial communic.
MS_uC / dnd / V08
4- 2
Typical serial communication
(low level)
Full-duplex interface
Receive
Transmit
Device 1
Transmit
Receive
-PC
-embedded system
-modem
-barcode reader
-printer
-display (with terminal emulation software)
-data logger
-sensor (simple or complex)
-dongle (security element)
-I/O module (digital, analog, encoder, PT100)
-wireless interface
Device 2
-PC
-Embedded system
EIA-232-C pin assignments
D-Sub male on PC
UART - Serial communic.
MS_uC / dnd / V08
4- 3
Pin
DB9
Pin
DB25
Symbol
Direction
Text
1
8
DCD

Data Carrier Detect
2
3
Rx

Receive Data
3
2
Tx

Transmit Data
4
20
DTR

Data Terminal Ready
5
7
Gnd
6
6
DSR
7
4
RTS
8
5
CTS

Clear to Send
9
22
RI

Ring Indicator
Out In
Signal Ground

Data Set Ready
Request to Send

RS-232-C: Radio Sector, American Standard since 1969s
Male -> Stecker
Female -> Buchse
Serial data format
(logical representation)
UART - Serial communic.
MS_uC / dnd / V08
4- 4
0
msb
lsb
1
n
1-2 stop
bits
5-8 data bits
Parity bit if
enabled
start
time
lsb: least significant bit (20)
msb: most significant bit (2 db-1)
1 bit time = 1 / baudrate
Example: parity enabled, 2 stop bits
Normally one Byte is sent as 8 data bits
Or: One Byte is sent as 7 data bits + parity
Hyperterminal usage
UART - Serial communic.
MS_uC / dnd / V08
4- 5
Start -> Zubehör -> Kommunikation -> Hyperterminal
Go offline
Configure COM-Port: File->Properties
Xon/Xoff: Software handshake (Exchange on..)
<ctrl-q>/<ctrl-s>
both sides must implement this
software handshake. The sender
has to stop almost immediately
upon reception of Xoff character
Binary data transmission is not
possible.
Hardware:
RTS/CTS hardware handshake
garantees loss-free transmission
on a byte level and allows
binary data transmission
UART - Serial communic.
MS_uC / dnd / V08
4- 6
Hyperterminal communication
(no handshake)
a) Reset the controller. It will send a string
b) Now type some characters. The controller will echo them (not hyperterminal!)
 try BS character (<ctrl-H> backspace) The terminal will interprete it properly
 try LF character (<ctrl-J> line feed, 0x0D). The cursor will move one line down
 try CR charcter (<ctrl-M> carriage return, 0x0A). The cursor jumps to column 0
Serial ports may be simulated using the Simulator output and the serial window:
View -> Serial Window -> UART #0
UART – What is it good for?
UART - Serial communic.
MS_uC / dnd / V08
4- 7
 Simple serial communication (3-wire)
 Multiple physical interfaces:
EIA-232 Peer-to-peer (former RS-232-C 1969). Gnd based (-15..3,3..15 V)
EIA-485 Party Line, multi-point link (SCSI, ISDN, ...
EIA-422 : Balanced lines, no ground link (D+/D-) on drivers up
to 1'000m @ 100 kbps. Point-to-point or multi-drop. 0-5 V.
Twisted-pair cable
 Easy setup
 Direct programming
 Byte level only
 USB will not replace cheap and simple communications
EIA: Electronic Industry Alliance
Hardware flow control
UART - Serial communic.
MS_uC / dnd / V08
4- 8
RTS will be switched on and off by programmable receiv FIFO watermarks
UART features (1/3)
UART - Serial communic.
MS_uC / dnd / V08
4- 9
 Separate 16x8 Transmit and 16x12 Receive FIFO
 Programmable FIFO disabling for 1-byte depth
 Programmable Baud rate generator :
Baud rate = UARTCLK / (16 × BRR)
 Standard Asynchronous communication bits (start, stop and parity)
 Independent masking of transmit FIFO, receive FIFO, receive
timout, modem status, and error condition interrupts
 False start bit detection
 Line Break Generation and Detection
 Support for Modem Control Functions CTS, DCD, DSR, RTS, DTR,
and RI
 Programmable hardware flow control
FIFO: First In First Out sequential, buffer structure
UART - Serial communic.
MS_uC / dnd / V08
UART features (2/3)
4- 10
 Programmable word length :
5 bits, 6 bits, 7 bits, 8 bits
 Programmable Stop bits :
1 Stop bit, 2 Stop bits
 Even, odd, stick, or no-parity bit generation and detection
 Support for Direct Memory Access (DMA)
 Support for an IrDA Serial Interface (SIR) protocol EnDec
 Parity control
 Loop Back
 Support baud rates of up to 460.8 Kbits / second subject to
UARTCLK reference clock frequency
UART - Serial communic.
MS_uC / dnd / V08
UART features (3/3)
4- 11
 11 Interrupt sources :
Overrun error detected
Break Error
Parity Error
Framing Error
Receive Timeout
Data Transmit
Data Receive
Modem Data Set Ready (DSRMIM)
Modem Data Carrier Detect (DCD)
Modem Clear to Send (CTS)
Modem Ring Indicator (RI)
UART - Serial communic.
MS_uC / dnd / V08
4- 12
UART Block diagram
UART - Serial communic.
MS_uC / dnd / V08
4- 13
UART register map
UART - Serial communic.
MS_uC / dnd / V08
Fractional Baud Rate generator
4- 14
 Every baud rate generator has errors. Check the tolerance!
BRCLK: baud rate clock
UART - Serial communic.
MS_uC / dnd / V08
4- 15
[Peripherals -> UART]
UART configuration
UART - Serial communic.
MS_uC / dnd / V08
Pin connections of UART
4- 16
 Use COM1 of MCBSTR9. Which port?
P3.0 UART0_RxD Alternate Input 1
P3.1 UART0_TxD Alternate Output 2
STR91x ARM966 manual 12274.pdf, 4.1 pin functions page 36
UART - Serial communic.
MS_uC / dnd / V08
4- 17
Download