University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

Similar documents
University of Texas at El Paso Electrical and Computer Engineering Department

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

2.996/6.971 Biomedical Devices Design Laboratory Lecture 6: Microprocessors II

임베디드시스템기초 (# ) #11. Serial Communications 한림대학교전자공학과이선우

8051 Serial Port. EE4380 Fall02 Class 10. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Basics of UART Communication

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

MCS-51 Serial Port A T 8 9 C 5 2 1

8051 Timers and Serial Port

CPE 323: MSP430 Serial Communication

Embedded Systems - FS 2018

Serial Communications

Embedded Systems - FS 2018

Laboratory 5 Communication Interfaces

Embedded Systems. 3. Hardware Software Interface. Lothar Thiele. Computer Engineering and Networks Laboratory

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

School of Computer Science Faculty of Engineering and Computer Science Student ID Number. Lab Cover Page. Lab Date and Time:

Serial Communications

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -4 1 UNIT 4

Copyright 2015 by Stephen A. Zajac & Gregory M. Wierzba. All rights reserved..spring 2015.

Asynchronous Transmission. Asynchronous Serial Communications & UARTS

Lab 1: I/O, timers, interrupts on the ez430-rf2500

Sender Receiver Sender

ECE2049-E18 Lecture 6 Notes 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

Embedded Systems and Software. Serial Communication

Embedded Systems and Software

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

ECE2049-E17 Lecture 6 1. ECE2049: Embedded Computing in Engineering Design E Term Lecture #6: Exam Review

Laboratory Finite State Machines and Serial Communication

EEL 4924 Electrical Engineering Design (Senior Design) Team Baudiophile. Wireless Headphones

Fall 2017 Project Assignment Speed Trap

8051 Microcontroller

Universal Asynchronous Receiver / Transmitter (UART)

Pridgen Vermeer Robotics Xmega128 Manual

Serial Interfacing. Asynchronous Frame

OUTLINE. SPI Theory SPI Implementation STM32F0 SPI Resources System Overview Registers SPI Application Initialization Interface Examples

PD215 Mechatronics. Week 3/4 Interfacing Hardware and Communication Systems

Asynchronous & Synchronous Serial Communications Interface. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II

CPE 323 Introduction to Embedded Computer Systems: MSP430 System Architecture An Overview

CSCE 236 Embedded Systems, Fall 2017 Homework 5

Interrupts and Serial Communication on the PIC18F8520

EET203 MICROCONTROLLER SYSTEMS DESIGN Serial Port Interfacing

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

Serial Communication. Simplex Half-Duplex Duplex

To be familiar with the USART (RS-232) protocol. To be familiar with one type of internal storage system in PIC (EEPROM).

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #9: Exam Review w/ Solutions

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

ECE2049: Embedded Computing in Engineering Design A Term Fall Lecture #8: Making it work: LEDs, Buttons & Keypad

MCP 1200 Evaluation Board Guidance

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4465

PIXI click PID: MIKROE Weight: 28 g

PIC-I/O Multifunction I/O Controller

ECGR 4101/5101, Fall 2011: Lab 4 A pseudo physics simulator with remote communication.

A3-TFFCBL-02 USB-to-UART Adapter User Manual

ECE251: Thursday November 8

MSP430. More on MSP430

ARDUINO MICRO WITHOUT HEADERS Code: A000093

Microcontroller basics

ARDUINO LEONARDO WITH HEADERS Code: A000057

Hands-On: Implementing an RF link with MSP430 and CC1100

MSP430FG4618 Programming Reference Revision 3

melabs Serial LCD Firmware Version 1.0 2/7/07

TKT-3500 Microcontroller systems

CPE 325: Embedded Systems Laboratory Laboratory #11 Tutorial Analog-to-Digital Converter and Digital-to-Analog Converter

PAK-XI PS/2 Coprocessor Data Sheet by AWC

I Introduction to Real-time Applications By Prawat Nagvajara

Interfacing CMA3000-D01 to an MSP430 ultra low-power microcontroller

Concepts of Serial Communication

SPI Universal Serial Communication Interface SPI Mode

LCD03 - I2C/Serial LCD Technical Documentation

YOU WILL NOT BE ALLOWED INTO YOUR LAB SECTION WITHOUT THE REQUIRED PRE-LAB.

Communication. Chirag Sangani

Lab 4: Interrupt. CS4101 Introduction to Embedded Systems. Prof. Chung-Ta King. Department of Computer Science National Tsing Hua University, Taiwan

6. General purpose Input/Output

Preliminary File System User Manual

ARDUINO LEONARDO ETH Code: A000022

EE 354 November 13, 2017 ARM UART Notes

UNIT IV SERIAL COMMUNICATIONS

Serial Peripheral Interface (SPI) Last updated 8/7/18

EE251: Tuesday December 4

Interfacing a Hyper Terminal to the Flight 86 Kit

P4S-341 User Manual > Introduction. Overview

USB UART 4 click PID: MIKROE Weight: 23 g

Serial Peripheral Interface (SPI)

LCD03 - I2C/Serial LCD Technical Documentation

P4S-342 User Manual > Introduction. Overview

ESPino - Specifications

RL78 Serial interfaces

Keyboards. The PS/2 Protocol

Using the USART Serial Communications

Interrupts, timers and counters

LCD Module with I2C / Serial Interface and Keypad Control «LCD I2C/Serial» User s Guide. Copyright 2008 IMS

DEV-1 HamStack Development Board

Lab 8 RS232 October 22, 2015

Xbee module configuration from a µcontroller

Transcription:

University of Texas at El Paso Electrical and Computer Engineering Department EE 3176 Laboratory for Microprocessors I Fall 2016 LAB 08 UART Communication Goals: Learn about UART Communication and the 12 Button Keypad and interface two micros together. The transmitting micro (or receiving micro) should translate keypresses into characters like a phone. The receiving micro should display the received characters on the LCD Display. Bonus: (Choose 1) Display the changing characters in real time: the current character being changed should blink until the user has not pushed any buttons after a while. +10 Pre Lab Questions: Instead of transmitting to another micro, transmit the characters to a terminal program on the PC. Indicate data is being transmitted from the micro with the Green LED and that data is being received with the Red LED. +10 Why use UART? What baud rate did you use? Why? How does ASCII encoding work? Can you only transmit chars; why or why not?

UART Communication Lab Guide UART Communication comes in 2 modes: software and hardware. Both configurations are detailed in the various UART sections in the User s guide, but for simplicity s sake, UART in software mode allows us to use the RX and TX pins (P1.1 and P1.2, respectively) for communication. This mode is useful for transmitting info between two connected MSP430s. UART in hardware mode is useful for using the so called Back Channel, i.e. communication between the MSP430 and the PC. You can send data stored in the micro to the PC and vice versa. UART Data Transmission Data is sent in 10bit packets: one start bit, one stop bit and 8 character bits, which are encoded using the ASCII standard. The data packet is transmitted at a speed known as the Baud Rate, or bits per second. See the diagram below: Period = 1/Baud Data: D 2 0 1 0 1 1 0 1 0 0 1 Bits: Start 0 1 2 3 4 5 6 7 Stop LSB MSB Start bits are low while stop bits are high. Notice how the data is sent LSB first. The hex value is 2Dh, the value for the - (minus sign) in ASCII.

UART Setup Use the following settings in the supplied code to setup the UART: UCA0CTL0: USCI_A0 control Register 0 - Configure the register as such: No parity, LSB first, 8-bit data, 1 stop bit, UART, Asynchronous. UCA0CTL1: USCI_A0 control Register 1 - Use SMCLK as USCI clock source and enable software interrupts. Refer to Section 16.4.2 in the User s Guide. UCA0BR0: USCI_A0 Baud Rate Control Register 0 - Configure this 16-bit register to have a 1MHz frequency and 9600 Baud Rate. This value can be easily obtained from Table 15-4 in the MSP430 User s Guide. UCA0MCTL: USCI_A0 Modulation Control Register - Configure this register as such: 2nd Stage modulation = 1, Oversampling off. You can find the details for this register from Section 15.4.5 from the User s Guide. IFG2: Interrupt Flag Register 2 - Clear the flags. See Section 15.4.13. IE2: Interrupt Enable Register 2 - Enable UART interrupts. Section 15.4.12. P1DIR: This register controls all 8 pins of the Port 1, make the built-in LEDs to be outputs. P1OUT: The register that determines the value of all pins that are programmed as outputs by P1DIR. P2IN: The register that can be read to see the value of every pin; make sure to use P2DIR to make Port 2 pins as inputs. P1SEL & P1SEL2: These 2 registers control the function of each Pin in Port 1 (depending on the current module being used); you are responsible for finding the correct combination (from the datasheet) to enable the UART function on Pins P1.1 and P1.2 (RX and TX, respectively). You will be given a sample program with these settings already set. See how it functions and then apply the idea to this lab assignment. Be sure to have two separate projects; one for the receiving micro and one for the transmitting micro.

UART Connections Connection is simple. Only two wires are needed for communication in software mode, three if you want to include a ground wire so the receiving micro can be used without it being powered. Only the USB cable is needed for hardware mode. Also, you must change the jumper configuration on the top right side of the micro. See the appropriate diagrams below for the sample program: SOFTWARE TX RX P1.1 RX P1.1 RX P1.2 TX P1.2 TX P2.0 P2.1 P2.2 GND GND ⓿❶❷ External Buttons w/ Pulldown Resistors Jumper Configuration

HARDWARE TX PC USB USB P2.0 P2.1 P2.2 ⓿❶❷ External Buttons w/ Pulldown Resistors Jumper Configuration Keyboard Here you should see the characters you are pressing in the terminal program on the PC and the characters being received by the micro. The LEDs on the micro should react to characters being received from the PC. Notes: A sample program has been provided. Pressing Switch 0 should turn on the Red LED on the receiving micro; Switch 1 will turn on the Green LED; Switch 2 will turn on BOTH. When connecting to the PC: Switch 0 sends d ; Switch 1 sends i ; Switch 2 sends r. The Interrupt Vectors for the UART are only used for receiving and transmitting, but you can change the state of the LEDs in their ISRs. You can access the necessary Receive and Transmit Buffer Registers, UCA0RXBUF and UCA0TXBUF, in any fashion, but only using the ISR will allow you to have your code be non-blocking.

UART Communication Lab Hints There is no sample code to start with; instead you must know enough by now to be able to write the program from scratch. However, the general program flow will be described below: Include necessary headers Declare necessary global variables Initialize and configure necessary modules (Ports, Interrupts) You may poll or use interrupts to capture keypresses You can use interrupts to execute short code and have your main loop handle the main functions, such as Receive and Transmit, and to display your data on the LCD screen. Use the Receive and Transmit Buffer Registers. Fill the Transmit Buffer Register to transmit a character; when a character is received, the Receive Buffer Register will be filled and you can retrieve the character from it. Check the comments in source files/libraries provided. Make sure you understand what is happening in the sample programs provided. Below is a reference of how letters are derived from the key/button presses:

UART Communication Post Lab Lab Notebook Questions: Answer the following questions in your lab notebook: Explain in detail the 3 different types of communication protocols used by the MSP430 (SPI, IIC (aka I2C) and UART) and in what applications it would be advantageous to use one over the other.

UART Communication Frequently Asked Questions How can I receive a string; a character is not enough? Simply use a loop to wait until the UART is no longer busy by checking the UART IFG. If it is not busy, then retrieve a character from the Receive Buffer Register and store in your character array by incrementing the array index in each iteration of the loop. Stop when you reach the end of the array or after however many characters you want your string to be. and to transmit a string? Same idea but instead use the Transmit Buffer Register. Can I use more/other pins for UART; how many UARTs can I use? First, to clarify, true software UART mode doesn t use the UART module. Using the UART module, we are technically always using hardware mode, meaning pins P1.1 and P1.2 are almost always high. To keep them from interfering from other applications when not using the UART module, the first two jumpers from the left (the ones we rotate in the diagrams) should be removed. You can only use the UART module for one setup. In theory, you can use delays and maybe even the timer to create your own UART implemented in software, much like how you can generate a PWM with delays and setting a pin high or low, or also timer. But this would be more trouble than it be worth trying to get the timing perfect or even usable.