1 / 21

Programming Microcontroller USART Universal Synchronous/Asynchronous Receiver Transmitter

Programming Microcontroller USART Universal Synchronous/Asynchronous Receiver Transmitter Autumn 2012. Typical serial communication (low level). Full-duplex interface. Receive. Transmit. Device 1 (Data Set). Device 2 (Data Terminal). Transmit. Receive. -PC -embedded system - modem

brosh
Télécharger la présentation

Programming Microcontroller USART Universal Synchronous/Asynchronous Receiver Transmitter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Microcontroller USART Universal Synchronous/Asynchronous Receiver Transmitter Autumn 2012 UART - Serial communic.

  2. Typical serial communication(low level) UART - Serial communic. Full-duplex interface Receive Transmit Device 1 (Data Set) Device 2 (Data Terminal) 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 • PC • Embedded system

  3. RS-232-C pin assignmentsD-Sub male on PC UART - Serial communic. Male -> Stecker Female -> Buchse RS-232-C: Radio Sector, American Standard since 1969s EIA: Electronic Industry Alliance

  4. Serial data format(logical representation) UART - Serial communic. 1-2 stop bits msb lsb 1 5-8 data bits 0 n Parity bit if enabled start time lsb: least significant bit (20) msb: most significant bit (2 db-1) Normally one Byte is sent as 8 data bits Or: One Byte is sent as 7 data bits + parity 1 bit time = 1 / baud rate Example: parity enabled, 2 stop bits

  5. Hyperterminal usage UART - Serial communic. 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 guarantees loss-free transmission on a byte level and allows binary data transmission

  6. 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 UART – What is it good for? UART - Serial communic. EIA: Electronic Industry Alliance

  7. EIA-485 Party Line, multi-point link UART - Serial communic.

  8. Hardware flow control UART - Serial communic. nRTS will be switched on and off by programmable receiver DMA watermarks

  9. Full duplex, asynchronous communications NRZ standard format (Mark/Space) Fractional baud rate generator systems A common programmable transmit and receive baud rates up to 4.5 MBits/s Programmable data word length (8 or 9 bits) Configurable stop bits - support for 1 or 2 stop bits LIN (Local Interconnection Network) Master Synchronous Break send capability and LIN slave break detection capability 13-bit break generation and 10/11 bit break detection when USART is hardware configured for LIN Transmitter clock output for synchronous transmission IrDA SIR Encoder Decoder Support for 3/16 bit duration for normal mode Smartcard Emulation Capability The Smartcard interface supports the asynchronous protocol Smartcards as defined in ISO 7816-3 standards 0.5, 1.5 Stop Bits for Smartcard operation UART features (1/3) UART - Serial communic.

  10. Single wire half duplex communication Configurable multi buffer communication using DMA (direct memory access) Buffering of received/transmitted bytes in reserved SRAM using centralized DMA Separate enable bits for Transmitter and Receiver Transfer detection flags Receive buffer full Transmit buffer empty End of Transmission flags Parity control Transmits parity bit Checks parity of received data byte Four error detection flags Overrun error Noise error Frame error Parity error UART features (2/3) UART - Serial communic.

  11. Ten interrupt sources with flags: CTS changes LIN break detection Transmit data register empty Transmission complete Receive data register full Idle line received Overrun error Framing error Noise error Parity error Multiprocessor communication - enter into mute mode if address match does not occur Wake up from mute mode (by idle line detection or address mark detection) Two receiver wakeup modes: Address bit (MSB, 9th bit), Idle line UART features (3/3) UART - Serial communic.

  12. UART Block diagram UART - Serial communic. Ref. RM0008 Reference manual, figure 277

  13. UART register boundary addresses UART - Serial communic. Ref. RM0008 Reference Manual, table 3

  14. UART register offset addresses UART - Serial communic. Ref. RM0008 Reference Manual, table 198

  15. Status register (USART_SR) CTS: Clear to send TXE: Transmit data register empty TC: Transmission complete RXNE: Read data register not empty NE: Noise error FE: Frame error PE: Parity error Data register (USART_DR) Contains the received or transmitted data character, depending it is read from or written to UART register description (1/4) UART - Serial communic. Ref. RM0008 Reference Manual, chapter 27.6

  16. UART register description (2/4) UART - Serial communic. • Control register 1 (USART_CR1) • UE: USART enable • M: Word length • PCE: Parity control enable • PS: Parity selection • PEIE: Parity interrupt enable • TXEIE: TXE interrupt enable • TCIE: Transmission complete interrupt enable • RXNEIE: RXNE interrupt enable • TE: Transmitter enable • RE: Receiver enable

  17. UART register description (3/4) UART - Serial communic. • Control register 2 (USART_CR2) • STOP: Stop bits • CLKEN: Clock enable • CPOL: Clock polarity • CPHA: Clock phase

  18. UART register description (4/4) UART - Serial communic. • Control register 3 (USART_CR3) • CTSIE: CTS interrupt enable • CTSE: CTS enable • RTSE: RTS enable • DMAT: DMA enable transmitter • DMAR: DMA enable receiver • HDSEL: Half-duplex selection • EIE: Error interrupt enable

  19. The Baud rate for the receiver and transmitter (Rx & Tx) are both set to the same value USARTDIV is an unsigned fixed point number that is coded on the USART_BRR register Fractional Baud Rate generator UART - Serial communic.

  20. Error calculation for programmed baud rates UART - Serial communic. Ref. RM0008 Reference Manual, table 192

  21. USART2 port functional description PD5: Alternate push-pull PD6: Input floating USART2 port remap PD5 USART_TX PD6 USART_RX Pin connections of USART2 UART - Serial communic. RM0008 Reference manual, Table 53

More Related