programming microcontroller uart – universal asynchronous receiver transmitter 2007

17
4- 1 UART - Serial communi c. MS_uC / dnd / V08 Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007 32K Byte 32K Byte Burst Flash Burst Flash 64K or 96K 64K or 96K Byte SRAM Byte SRAM 256K or 512K 256K or 512K Byte Burst Byte Burst Flash Flash OTP OTP Mem Mem UART UART I2C I2C SPI SPI TIM TIM RTC RTC EXT. EXT. Bus Bus GPIO GPIO USB USB 2.0FS 2.0FS CAN CAN 2.0B 2.0B Enet Enet MAC MAC PFQ PFQ BC BC DMA DMA INTR INTR Cntl Cntl ARM966E ARM966E CORE CORE w/DSP w/DSP 96 MHz 96 MHz CLK CLK Cntl Cntl ADC ADC LVD LVD BOD BOD PLL PLL JTAG JTAG ETM9 ETM9 STR912FW44

Upload: chibale

Post on 18-Mar-2016

75 views

Category:

Documents


2 download

DESCRIPTION

Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007. 64K or 96K Byte SRAM. Enet MAC. ARM966E. CORE. w/DSP. USB 2.0FS. 96 MHz. 256K or 512K Byte Burst Flash. PFQ BC. CAN 2.0B. DMA. INTR Cntl. CLK Cntl. 32K Byte Burst Flash. GPIO. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 1

UART - Serial communic.

MS_uC / dnd / V08

Programming MicrocontrollerUART – Universal Asynchronous Receiver Transmitter

2007

32K Byte 32K Byte Burst FlashBurst Flash

64K or 96K 64K or 96K Byte SRAM Byte SRAM

256K or 512K 256K or 512K Byte Burst Byte Burst

FlashFlash

OTP OTP MemMem

UARTUARTI2CI2CSPISPITIMTIMRTCRTC

EXT. EXT. Bus Bus

GPIOGPIO

USB USB 2.0FS 2.0FS CAN CAN 2.0B 2.0B

Enet Enet MAC MAC

PFPFQ Q

BC BC DMADMA

INTINTR R

CntlCntl

ARM96ARM966E 6E CORE CORE

w/DSPw/DSP96 MHz 96 MHz

CLK CLK CntlCntl

ADCADC

LVD LVD BODBOD PLLPLL JTAJTA

GGETMETM

99

STR912FW44

Page 2: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 2

UART - Serial communic.

MS_uC / dnd / V08

Typical serial communication(low level)

Full-duplex interface

Device 1 Device 2

-PC-Embedded system

-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

Transmit

ReceiveTransmit

Receive

Page 3: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 3

UART - Serial communic.

MS_uC / dnd / V08

EIA-232-C pin assignmentsD-Sub male on PC

PinDB9

PinDB25

Symbol Direction

Text

Out

In

1 8 DCD Data Carrier Detect2 3 Rx Receive Data3 2 Tx Transmit Data4 20 DTR Data Terminal Ready5 7 Gnd Signal Ground6 6 DSR Data Set Ready7 4 RTS Request to Send

8 5 CTS Clear to Send9 22 RI Ring Indicator

RS-232-C: Radio Sector, American Standard since 1969s

Male -> SteckerFemale -> Buchse

Page 4: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 4

UART - Serial communic.

MS_uC / dnd / V08

Serial data format(logical representation)

5-8 data bits

Parity bit if enabled

1-2 stop bitsmsblsb

start

1

n0

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 bitsOr: One Byte is sent as 7 data bits + parity

Page 5: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 5

UART - Serial communic.

MS_uC / dnd / V08Hyperterminal usage

Start -> Zubehör -> Kommunikation -> HyperterminalGo offlineConfigure COM-Port: File->Properties

Xon/Xoff: Software handshake (Exchange on..)<ctrl-q>/<ctrl-s>

both sides must implement thissoftware handshake. The senderhas to stop almost immediatelyupon reception of Xoff characterBinary data transmission is notpossible.

Hardware: RTS/CTS hardware handshakegarantees loss-free transmissionon a byte level and allows binary data transmission

Page 6: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 6

UART - Serial communic.

MS_uC / dnd / V08

Hyperterminal communication(no handshake)

a) Reset the controller. It will send a stringb) 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

View -> Serial Window -> UART #0Serial ports may be simulated using the Simulator output and the serial window:

Page 7: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 7

UART - Serial communic.

MS_uC / dnd / V08UART – What is it good for?

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

Page 8: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 8

UART - Serial communic.

MS_uC / dnd / V08Hardware flow control

RTS will be switched on and off by programmable receiv FIFO watermarks

Page 9: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 9

UART - Serial communic.

MS_uC / dnd / V08UART features (1/3)

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

Page 10: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 10

UART - Serial communic.

MS_uC / dnd / V08UART features (2/3)

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

Page 11: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 11

UART - Serial communic.

MS_uC / dnd / V08UART features (3/3)

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)

Page 12: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 12

UART - Serial communic.

MS_uC / dnd / V08

UART Block diagram

Ref manual figure 74

Page 13: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 13

UART - Serial communic.

MS_uC / dnd / V08UART register map

Page 14: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 14

UART - Serial communic.

MS_uC / dnd / V08Fractional Baud Rate generator

Every baud rate generator has errors. Check the tolerance!

BRCLK: baud rate clock

Page 15: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 15

UART - Serial communic.

MS_uC / dnd / V08UART configuration

[Peripherals -> UART]

Page 16: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 16

UART - Serial communic.

MS_uC / dnd / V08Pin connections of UART

STR91x ARM966 manual 12274.pdf, 4.1 pin functions page 36

P3.0 UART0_RxD Alternate Input 1P3.1 UART0_TxD Alternate Output 2

Use COM1 of MCBSTR9. Which port?

Page 17: Programming Microcontroller UART – Universal Asynchronous Receiver Transmitter 2007

4- 17

UART - Serial communic.

MS_uC / dnd / V08