0% found this document useful (0 votes)
37 views

Embedded Systems Engineering Lecture 08 (UART)

The document discusses serial communication using UART with the MSP430FR5739 microcontroller. It covers the basics of serial vs parallel communication, different types of serial protocols, and provides code examples for setting up UART communication on the MSP430 including pin configuration, register setup, baud rate calculation, and a polling transmit/receive loop.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Embedded Systems Engineering Lecture 08 (UART)

The document discusses serial communication using UART with the MSP430FR5739 microcontroller. It covers the basics of serial vs parallel communication, different types of serial protocols, and provides code examples for setting up UART communication on the MSP430 including pin configuration, register setup, baud rate calculation, and a polling transmit/receive loop.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

EC3462

Embedded Systems
Engineering
lecture 08 – Serial
Communication with
MSP430FR5739 -
UART
By Nushara Wedasingha
Mphi(AI) Candidate, Bsc.(Hons) EEE
Department of Electrical and Electronic
Faculty of Engineering
Sri Lanka Institute of Information Technology
WHY
COMMNUICATIO
N IS IMPORTANT?
Data communication
Data Communication

Serial Communication Parallel Communication

• Sends data, sequentially, • Sends several data


one bit at a time over signals/bits
a communication channel. simultaneously over
Ex: - SPI, I2C, CAN several parallel channels.
Ex: - ISA, ATA, SCSI, PCI
Advantages of Serial
Communication
• Needs less amount of wires.
• Consumes less number of pins from Ics.
• A little space is enough.
• Speed has been improved over the years and is not an issue any more.
• Lot of MCUs provide built-in serial communication modules that can be easily
configured.
Types of serial communication

Synchronous – needs a common communication clock signal for the two


communicating devices
Asynchronous – no need of a common communication clock. Instead use
additional bits to maintain data stream.
Serial Communication in MSP430

Serial Communication

Universal Asynchronous
Serial Peripheral Interface Inter-Integrated Circuit
Receiver and Transmitter
(SPI) (I2C)
(UART)
Main Registers Offers Serial
Communication in MSP430
MSP430FR5739 Serial
Communication

eUSCI_A0 eUSCI_A1 eUSCI_B0

UART With Automatic UART With Automatic I2C With Multiple-Slave


Baud-Rate Detection Baud-Rate Detection Addressing
IrDA Encode and Decode IrDA Encode and Decode SPI

SPI SPI
Serial Communication MSP430
Architecture
Serial Communication MSP430
Architecture
Universal Asynchronous Receiver
Transmitter (UART)
• UART is one of asynchronous methods sending and receving serial data between two micro controllers.
• The transmition speed of the data between the micro controllers depends on the baud rate.
• Length of a data packet transmitted in UART is 12 bits.

Start Bit Data Bit Parity Bit Stop Bit

1Bit 8 Bit 1 Bit 1/2 Bit


Parity bit

• A bit which acts as a check on a set of binary values, calculated in such a way that
the number of 1s in the set plus the parity bit should always be even or odd.
• A word has even parity if the number of 1’s is even, and odd parity otherwise.
Serial
Communicatio
n MSP430
Architecture
Flow of Setting UART
Pin Configuration

Register Configurations

Baudrate Configuration

Starting UART Operation

Polling Loop
Registers
Name of Register Purpose
UCAxCTL0
Control Registers
UCAxCTL1
UCAxBRW Baud Rate
UCAxMCTL Modulating the Transmitting Signal
UCAxTXBUF Transmitter Buffer
UCAxRXBUF Receiver Buffer
UCAxSTAT Status
UCBUSY Busy
UCAxCTL
0
UCAxCTL
1
UCAMCTL
Baud Rate Calculation

𝐹 𝐵𝑅𝐶𝐿𝐾
𝑁=
𝐵𝑎𝑢𝑑 𝑅𝑎𝑡𝑒
𝑁 − 𝐷𝑖𝑣𝑖𝑠𝑖𝑜𝑛 𝐹𝑎𝑐𝑡𝑜𝑟 , 𝐹𝐵𝑅𝐶𝐿𝐾 − 𝐶𝑙𝑜𝑐𝑘 𝑜𝑓 𝑡h𝑒 𝐵𝑜𝑎𝑟𝑑

Selecting Buad Rate,

UCBRW = INT (N)


Baud Rate Calculation
Lets Code
Methodology of Coding
Pin Configuration

Register Configurations

Baudrate Configuration

Starting UART Operation

Polling Loop
An example on uart_a0 –pin
configuration
/* P2.1 is RX*/
/* P2.0 is TX*/
/* hence select SECONDARY FUNCTION for P2.0 and P2.1*/
P2SEL1 |= (BIT1|BIT0);
P2SEL0 &= ~(BIT1|BIT0);
An example on uart_a0 –start
configuring registers

UCA0CTLW0 |= UCSWRST; //set UCSWRST to


configure settings
An example on uart_a0 – configuring
registers
UCA0CTLW0 &= ~UCPEN; //disable parity
UCA0CTLW0 &= ~UCMSB; //select little endian mode
UCA0CTLW0 &= ~UC7BIT; //select 8bit data
UCA0CTLW0 &= ~UCSPB; //select one stop bits
UCA0CTLW0 &= ~(UCMODE1|UCMODE0); //select UART mode
UCA0CTLW0 &= ~UCSYNC; //select asynchronous mode
UCA0CTLW0 |= (UCSSEL1|UCSSEL0); //select SMCLK
An example on uart_a0 – configuring
baudrate

UCA0MCTLW |= UCOS16;
UCA0BRW = 6;
UCA0MCTLW = (0X0011<<8 | 0X0008<<4 |
0x0001<<0);
An example on uart_a0 –start uart
operation

UCA0CTLW0 &= ~UCSWRST; //clear UCSWRST to start


operation
An example on uart_a0 –polling loop

while (1)
{
while (!(UCA0IFG & UCRXIFG));
UCA0TXBUF = UCA0RXBUF;
}
Thank You

You might also like