The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters Refer to Chapter 13 in the reference book “Stellaris®

Slides:



Advertisements
Similar presentations
EUSART Serial Communication.
Advertisements

INPUT-OUTPUT ORGANIZATION
Serial Communications Interface (SCI) Michael LennardZachary PetersBao Nguyen.
11-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL I/O System Design.
FPGA Configuration. Introduction What is configuration? – Process for loading data into the FPGA Configuration Data Source Configuration Data Source FPGA.
ECT 357 Ch 18 UART. Today’s Quote: Be careful that your marriage doesn’t become a duel instead of a duet. Be careful that your marriage doesn’t become.
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
Programmable Keyboard/ Display Interface: 8279
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
Microprocessor and Microcontroller
Serial I/O - Programmable Communication Interface
COMP3221: Microprocessors and Embedded Systems Lecture 22: Serial Input/Output (II) Lecturer: Hui Wu Session 1, 2005.
Refer to Chapter 6, 9 in the reference book
Asynchronous Communication Hardware  Data within a DTE is usually stored and moved in a parallel fashion.  Data sent across the channel is generally.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
1 The 9-Pin Connector Pin abbreviations (numbers in parentheses are the 25D pin numbers): 1. CD (8) 2. RD (Rx) (3) 3. TD (Tx) (2) 4. DTR (20) 5. SG (Ground)
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – System Control Refer to Chapter 6 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface.
INPUT-OUTPUT ORGANIZATION
Serial Communication Interface (SCI) Kevin Stuart Matt Betts March 27, 2007 ME 6405, Sp 07.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
The University of New Hampshire InterOperability Laboratory Serial ATA (SATA) Protocol Chapter 10 – Transport Layer.
SC200x Peripherals Broadband Entertainment Division DTV Source Applications July 2001.
Lecture 26: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters.
Input/Output mechanisms
Lecture 29: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM)
Lecture 23: LM3S9B96 Microcontroller - Interrupts.
Lecture 7 Universal Asynchronous Receiver/Transmitter (UART) NCHUEE 720A Lab Prof. Jichiang Tsai.
Chapter 4 TIMER OPERATION
Lecture Set 9 MCS-51 Serial Port.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
Unit 4 Design and Synthesis of Datapath Controllers
Lecture 14 DMA Controller & Serial Communications Interface (UART)
Universal Asynchronous Receiver/Transmitter (UART)
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
Lecture 25: LM3S9B96 Microcontroller – Watchdog Timer.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
Example. SBUF Register SCON Register(1) SCON Register(2)
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
NS Training Hardware. Serial Controller - UART.
PCA9557: REMOTE 8-BIT I 2 C AND SMBus LOW- POWER I/O EXPANDER.
Universal Asynchronous Receiver/Transmitter (UART)
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
Refer to Chapter 15 in the reference book
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
Lecture 4 General-Purpose Input/Output NCHUEE 720A Lab Prof. Jichiang Tsai.
Lecture 22: LM3S9B96 Microcontroller – SysTick and General-Purpose Timers.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Watchdog Timers Refer to Chapter 11 in the reference book “Stellaris® LM3S9B96 Microcontroller.
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
8251 USART.
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
TM Freescale Confidential Proprietary Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names.
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Serial mode of data transfer
Refer to Chapter 16 in the reference book
Chapter 11: Inter-Integrated Circuit (I2C) Interface
Refer to Chapter 10 in the reference book
Serial I/O and Data Communication.
SERIAL PORT PROGRAMMING
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Computer Organization and Design
Source: Serial Port Source:
Asynchronous Serial Communications
Serial Communication Interface: Using 8251
Programmable Data Communication Blocks
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
EUSART Serial Communication.
Source: Serial Port Source:
Presentation transcript:

The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters Refer to Chapter 13 in the reference book “Stellaris® LM3S9B96 Microcontroller - DATA SHEET”

Universal Asynchronous Receivers/Transmitters (UARTs) zThe Stellaris LM3S9B96 controller includes three UARTs with the following features: zProgrammable baud-rate generator (up to 5Mbps for regular speed or 10 Mbps for high speed) zSeparate 16-entry transmit (TX) and receive (RX) FIFOs zProgrammable FIFO length zFIFO trigger levels of 1/8, 1/4, 1/2, 3/4, and 7/8 zFalse-start bit detection zLine-break generation and detection zFully programmable serial interface characteristics (data bits, parity bit, stop bits) zStandard FIFO-level and End-of-Transmission interrupts

Universal Asynchronous Receivers/Transmitters (UARTs) zIrDA serial-IR (SIR) encoder/decoder providing zSupport for communication with ISO 7816 smart cards zFull modem handshake support (on UART1) zLIN protocol support zEfficient transfers using Micro Direct Memory Access Controller (μDMA)

Block Diagram

Functional Description zEach UART performs the functions of parallel-to-serial and serial-to-parallel conversions zThe UART is configured for transmit and/or receive via the TXE and RXE bits of the UART Control (UARTCTL) register, enabled by default zthe UART must be disabled by clearing the UARTEN bit in UARTCTL before being programmed zThe UART module also includes a serial IR (SIR) encoder/decoder block that can be connected to an infrared transceiver to implement an IrDA SIR physical layer

Transmit/Receive Logic zThe transmit logic performs parallel-to-serial conversion on the data read from the transmit FIFO zbeginning with a start bit zthe data bits (LSB first) zparity bit, and the stop bits (according to the programmed configuration) zThe receive logic performs serial-to-parallel conversion on the received bit stream zafter detecting a valid start pulse zOverrun, parity, frame error checking, and line-break detection zStatus and data are written to the receive FIFO

Baud-Rate Generation zThe baud-rate divisor (BRD) is a 22-bit number za 16-bit integer: can be loaded through the UART Integer Baud- Rate Divisor (UARTIBRD) register za 6-bit fractional part: can be loaded with the UART Fractional Baud-Rate Divisor (UARTFBRD) register zBRD = BRDI + BRDF = UARTSysClk / (ClkDiv * Baud Rate) zUARTSysClk is the system clock zClkDiv (baud factor) is either 16 (if HSE in UARTCTL is clear) or 8 (if HSE is set) zBRDI is loaded to UARTIBRD zinteger(BRDF * ) is loaded to UARTFBRD

Baud-Rate Generation zThe UART generates an internal baud-rate reference clock at 8x (Baud8) or 16x (Baud16) the baud-rate (depending on the setting of the HSE bit (bit 5) in UARTCTL) zThis reference clock is divided by 8 or 16 to generate the transmit clock and for error detection during receive operations zany changes to the baud-rate divisor must be followed by a write to a UARTLCRH register for the changes to take effect zUARTIBRD write / UARTFBRD write, and UARTLCRH write

Data Transmission zData received or transmitted is stored in two 16-byte FIFOs zThe receive FIFO has an extra four bits per character for status information zFor transmitter: zdata is written into the transmit FIFO zIf the UART is enabled, a data frame starts transmitting with the parameters indicated in the UARTLCRH register zThe BUSY bit in the UART Flag (UARTFR) register is asserted as soon as there is data in the transmit FIFO zThe BUSY bit remains asserted while data is being transmitted until the transmit FIFO is empty

Data Transmission zFor receiver: zChecks a start bit: When data input goes low (a start bit) from high (idle) for eight cycles of Baud16 (HSE clear) or four cycles of Baud8 (HSE set) zSamples a data bit: the receive counter begins running and data is sampled on the eighth cycle of Baud16 or fourth cycle of Baud8 zDetected invalid start bit is ignored zThe parity bit is then checked if parity mode is enabled zFrame is defined in the UARTLCRH register zLastly, a valid stop bit is confirmed if the UnRx signal is High, otherwise a framing error has occurred

FIFO Operation zThe UART has two 16-entry FIFOs: one for Rx, one for Tx zBoth FIFOs are accessed via the UART Data (UARTDR) register zRead operations return a 12-bit value consisting of 8 data bits and 4 error flags zWrite operations place 8-bit data in the transmit FIFO zOut of reset, both FIFOs are disabled and act as 1-byte-deep holding registers (the bottom word of the FIFOs)) zThe FIFOs are enabled by setting the FEN bit in UARTLCRH zFIFO status can be monitored via the UART Flag (UARTFR) register and the UART Receive Status (UARTRSR) register: the UARTFR register contains empty and full flags (TXFE, TXFF, RXFE, and RXFF bits), and the UARTRSR register shows overrun status via the OE bit

FIFO Operation zThe trigger points at which the FIFOs generate interrupts is controlled via the UART Interrupt FIFO Level Select (UARTIFLS) register zBoth FIFOs can be individually configured zAvailable configurations include ⅛, ¼, ½, ¾, and ⅞ zFor example, if ¾ is selected for the receive FIFO, the UART generates an interrupt after ¾ X 16 = 12 bytes are received zOut of reset, both FIFOs are configured to trigger an interrupt at the ½ mark

Interrupts zThe UART can generate interrupts when the following conditions are observed: zOverrun Error zBreak Error zParity Error zFraming Error zReceive Timeout zTransmit (when condition defined in the TXIFLSEL bit in the UARTIFLS register is met, or when the last bit of all transmitted data leaves the serializer, i.e., EOT bit in UARTCTRL) zReceive (when condition defined in the RXIFLSEL bit in the UARTIFLS register is met)

Interrupts zAll of the interrupt events are ORed together before being sent to the interrupt controller zSoftware can service multiple interrupt events in a single ISR by reading the UART Masked Interrupt Status (UARTMIS) register zThe interrupt events can be masked via the UART Interrupt Mask (UARTIM) register zIf interrupts are not used, the raw interrupt status is always visible via the UART Raw Interrupt Status (UARTRIS) register

Interrupts zInterrupts are always cleared for both the UARTMIS and UARTRIS registers, when writing a 1 to the corresponding bit in the UART Interrupt Clear (UARTICR) register zWhen the receive FIFO is not empty, and no further data is received over a 32-bit period, a receive timeout interrupt is asserted zThe receive timeout interrupt is cleared: zwhen the FIFO becomes empty through reading all the data zwhen a 1 is written to the corresponding bit in the UARTICR register

Loopback Operation zThe UART can be placed into an internal loopback mode for diagnostic or debug work zSet the LBE bit in the UARTCTL register zData transmitted on the UnTx output is received on the UnRx input zNote that the LBE bit should be set before the UART is enabled

Register Map zThe UART’s base address: zUART0: 0x4000.C000 zUART1: 0x4000.D000 zUART2: 0x4000.E000

Register Description: UARTDR, offset 0x000 zThis register is the data register (the interface to the FIFOs). zA write to this register initiates a transmission from the UART zThe received data can be retrieved by reading this register Overrun Error: New data was received when the FIFO was full Break Error: the receive data input was held Low for longer than a full-frame transmission time Framing Error: The received character does not have a valid stop bit

Register Description: UARTFR, offset 0x018 zThis register is the flag register. TXFE:UART Transmit FIFO Empty RXFF:UART Receive FIFO Full TXFF:UART Transmit FIFO Full RXFE:UART Receive FIFO Empty BUSY:UART is busy transmitting data (This bit is set as soon as the transmit FIFO becomes non-empty)

Register Description: UARTLCRH, offset 0x02C zThis register is the line control register zSet up serial parameters such as data length, parity, and stop bit selection zWhen updating the baud-rate divisor (UARTIBRD and/or UARTIFRD), the UARTLCRH register must also be written WLEN:UART Word Length, 5, 6, 7, 8 bits FEN:UART Enable FIFOs STP2:UART Two Stop Bits Select EPS:UART Even Parity Select PEN:UART Parity Enable BRK:UART Send Break

Register Description: UARTCTL, offset 0x030 zThis register is the control register zIf software requires a configuration change in the module, the UARTEN bit must be cleared before the configuration changes are written zSequence for making changes: 1.Disable the UART. 2.Wait for the end of transmission or reception of the current character 3.Flush the transmit FIFO by clearing bit 4 (FEN) in the line control register (UARTLCRH) 4.Reprogram the control register 5.Enable the UART

Register Description: UARTCTL

Register Description: Others UART Integer Baud-Rate Divisor (UARTIBRD) UART Fractional Baud-Rate Divisor (UARTFBRD) UART Interrupt FIFO Level Select (UARTIFLS) UART Interrupt Mask (UARTIM) UART Raw Interrupt Status (UARTRIS) UART Masked Interrupt Status (UARTMIS) UART Interrupt Clear (UARTICR)

Initialization and Configuration zTo enable and initialize the UART, the following steps are necessary: z1. The peripheral clock must be enabled by setting the UART0, UART1, or UART2 bits in the RCGC1 register z2. The clock to the appropriate GPIO module must be enabled via the RCGC2 register in the System Control module z3. Set the GPIO AFSEL bits for the appropriate pins z4. Configure the GPIO current level and/or slew rate as specified for the mode selected z5. Configure the PMCn fields in the GPIOPCTL register to assign the UART signals to the appropriate pins

Initialization and Configuration zUsing UART with an example: the UART clock is 20MHz, baud rate, data length of 8 bits, one stop bit, no parity, FIFOs disabled, no interrupts zGet the appropriate baud-rate divisor (BRD) first since the UARTIBRD and UARTFBRD registers must be written before the UARTLCRH register BRD = 20,000,000 / (16 * 115,200) = Therefore, UARTIBRD = 10, UARTFBRD = integer( * ) = 54

Initialization and Configuration zWith the BRD values, the UART configuration is written to the module in the following order: z1. Disable the UART (clear the UARTEN bit in the UARTCTL register) z2. Write the integer portion of the BRD to the UARTIBRD register z3. Write the fractional portion of the BRD to the UARTFBRD register z4. Write the desired serial parameters to the UARTLCRH register (0x in this case) z5. Enable the UART (set the UARTEN bit in the UARTCTL register) NOTE 1: the UART module clock must be enabled before the registers can be programmed NOTE 2: The UART must be disabled before any of the control registers are reprogrammed