Objectives. Introduction

Similar documents
Asynchronous Data Transfer

Dallas Semiconductor DS1307 Real Time Clock. The DS 1307 is a real-time clock with 56 bytes of NV (nonvolatile)

MCO556 Practice Test 2

A B C D E F 0480 FE B F5 3B FC F3 E 1A 1D 2A 2D 3A 3D 4A 4D 5A 5D 6A 6D 7A 7D

HCS12 Serial Communications Interface (SCI) Block Guide V02.06

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Review for Exam 3. Write 0x05 to ATD0CTL4 to set at fastest conversion speed and 10-bit conversions

digital I/O lines which can be configured as inputs or as outputs; the output driver can be either opencollector/open-drain

In the HEW, open a new project by selecting New workspace from the main menu.

Lecture 13 Serial Interfaces

Functional block diagram AD53x1 (Analog Devices)

Embedded Systems and Software. Serial Communication

CS/ECE 5780/6780: Embedded System Design

Embedded Systems and Software

Interfacing a Hyper Terminal to the Flight 86 Kit

ECE/CS 5780/6780: Embedded System Design

1. Specifications Functions Used Operation Software Flowcharts Program Listing... 13

MICROPROCESSOR BASED SYSTEM DESIGN

RL78 Serial interfaces

PCA9665; PCA9665A. 1. General description. 2. Features and benefits. Fm+ parallel bus to I 2 C-bus controller

Lab 13 Real Time Debugging

=0 Read/Write IER Interrupt Enable Register =1 Read/Write - Divisor Latch High Byte + 2

NEW CEIBO DEBUGGER. Menus and Commands

UART Implementation Using the N2HET

Lecture1: introduction. Outline: History overview Central processing unite Register set Special purpose address registers Datapath Control unit

A6 CCTALK MODULAR VALIDATOR

Freescale Semiconductor, I

EB-51 Low-Cost Emulator

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

Lab 7: Asynchronous Serial I/O

Serial Communication

1. Implemented CM11 protocol

8051 Serial Communication

RX Family APPLICATION NOTE. Simple I 2 C Module Using Firmware Integration Technology. Introduction. Target Device.

Understand the design and operation of the SCI and the I 2 C, IrDA and Smart Card interfaces

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

TMS320LF240x-A Flash Programming

CONNECTING YOUR PC TO THE USB EVALUATION BOARD

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

SCI Driver for the MC9S08GW64

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

QUESTION BANK CS2252 MICROPROCESSOR AND MICROCONTROLLERS

Embedded programming, AVR intro

HI-WAVE. Serial Debug Interface SDI target. Copyright 1997 HIWARE HI-WAVE

Lab 8 RS232 October 22, 2015

Informatics for industrial applications

CAN Protocol Implementation

C Language Programming, Interrupts and Timer Hardware

8051 Microcontroller

Embedded Systems. Read pages

systems such as Linux (real time application interface Linux included). The unified 32-

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

Freescale Semiconductor, Inc. Debugger. Serial Debug Interface SDI target. Copyright Metrowerks Debugger

The purpose of this course is to provide an introduction to the RL78's flash features and archectecture including security features, code and data

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

Unit-I. 1. INTRODUCTION TO MICROCONTROLLERS. Micro controller, types, selection of a microcontroller and applications

EC6504 MICROPROCESSOR AND MICROCONTROLLER

Lecture 1: Introduction to Microprocessors

Chaper 1: E10+ PLCs Host-Link Command Format

Concepts of Serial Communication

Asynchronous Transfer of Data with Appended CRC Codes via an SCI Interface

FIFTH SEMESTER B.TECH DEGREE EXAMINATION MODEL TEST QUESTION PAPER, NOVEMBER CS 305: Microprocessor and Microcontrollers PART A

Table of Contents. DELTA ELECTRONICS, INC. ALL RIGHTS RESERVED i

OVERVIEW HARDWARE. C167 / ST10-F168 CAN Bus Programming and Simulation

Basics of UART Communication

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

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

Configurable UART with FIFO ver 2.20

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

Lecture 10. Serial Communication

Emulating an asynchronous serial interface (ASC0) via software routines

Module 3.C. Serial Peripheral Interface (SPI) Tim Rogers 2017

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

Asynchronous Serial Communication Protocol (without Flow Control) using TLM 2.0 (Example of Non memory based protocol )

EE 354 November 13, 2017 ARM UART Notes

TMS470R1x Serial Communication Interface (SCI) Reference Guide

Design UART Loopback with Interrupts

Input/Output Programming

2. (2 pts) If an external clock is used, which pin of the 8051 should it be connected to?

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

Topics. Interfacing chips

27.7 SCI Control Registers

minimon Simple CAN Monitoring Tool for Windows

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

1. Attempt any three of the following: 15

The CMXBug Manual. The CMXBug Manual

Am186ER/Am188ER AMD continues 16-bit innovation

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

AP16050 SAB C161V/K/O. Emulating an asynchronous serial interface (ASC) via software routines. Microcontrollers. Application Note, V 1.0, Feb.


ECE3120: Computer Systems Hardware & Software Development Tools

SPART. SPART Design. A Special Purpose Asynchronous Receiver/Transmitter. The objectives of this miniproject are to:

EUROScope lite 16FX Reference Manual

An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus

EE 3170 Microcontroller Applications

Transcription:

Objectives - To establish bidirectional communications with an external host computer via the serial interface of the microcontroller - To write a set of functions f the input and output of clear text and numerical data from and to a terminal program Introduction Serial communication is central to many embedded computer systems. Being able to communicate with a microcontroller through its Serial Communication Interface (SCI) provides the developer with eyes to see what is going on inside the chip. When wking with a new microcontroller, one of the first tasks commonly is the writing of a few communication routines through which err messages and status infmation can be displayed and control signals can be passed to the program. The MC9S12DP256B/C comes with two independent serial interface units (SCI0 and SCI1). A small memy resident monit program has been installed on all Dragon12 boards in our labaty. This program is started upon a hardware reset. It uses interface SCI0 to communicate with an external debugger on the host, e.g. the Hi- Wave source level debugger which has been integrated into the CodeWarri IDE. The monit/debugger facilitates the download of user programs into RAM Flash EEPROM, as well as their on-chip debugging using hardware breakpoints; hardware breakpoints allow a program to be interrupted, even if it has been installed in ROM. Interface SCI0 is configured f a line speed of 115200 bps, with 8 data bits, no parity checking and one stop bit (115200-8/N-1). The second serial communication interface, SCI1, is available f general use. 1 Figure LMP6-1 shows the principal elements of an SCI unit on the MC9S12DP256B/C. The line speed is controlled by programming the baud rate generat. This unit produces an internal clock signal which determines the timing on both the transmission line (sci_tx_od) as well as the reception line (sci_rx_ind). Incoming data is sted in the Receive Shift Register befe being copied to the SCI Receive Data Register. Similarly, outgoing data needs to be written to the SCI Transmit Data Register, from where it is copied to the Transmit Shift Register. Note that both the Transmit Data register as well as the Receive Data register are memy mapped at the same address. Read instructions to this address accesses the Receive Data register, whereas write instructions addresses the Transmit Data register. All special function registers of the SCI unit are shown in Figure LM6-2. The unit offset is to be added to the base address of the selected SCI unit in the memy map of the MC9S12DP256B/C. This is commonly done within header file which defines all special function registers (here: mc9s12dp256.h). 1 Note: Strictly speaking, both serial communication interfaces are f general use provided no serial pt based debugging is required. 1

Figure LMP6-1 The Serial Communication Interface (SCI) Figure LMP6-2 The special function registers of the SCI unit The line speed of the SCI unit is controlled through the two 8-bit SCI BauD Rate Registers, SCIBDH and SCIBDL (Figure LMP6-3). The 13-bit value (BR = [SBR12 SBR0]) defines a pre-scale value which is used to reduce the input clock of the SCI unit to the required line speed. This SCI input clock is 1/16 th of the central bus clock, i. e. 24 MHz / 16 = 1.5 MHz. The baud rate can thus be calculated using: f line fbus = 16 BR 2

Figure LMP6-2 The special function registers of the SCI unit Writing to the high byte of the baud rate register is ineffective until the low-byte has been written as well. Complete the following table to wk out the required values f the specified baud rates (Table LMP6-1). Baud rate (bps) BR SCIxBDL SCIxBDH Err (rel.) 1200 1250 226 4 0 % 2400 4800 313 312 57 56 1-0.16 % +0.16 % 9600 19200 78 78 0 +0.16 % 38400 57600 115200 Table LMP6-1 Baud rate generation, 24 MHz bus clock Note that some of the above baud rates can not be produced without err. Dividing the CPU clock rate (24 MHz) by 16 19200 307200 yields 78.125, i. e. a fractional 3

number. The nearest integer number is 78. Therefe, when requesting a line speed of 19200 bps, the baud rate generat actually generates a clock signal of 24 10 6 / (16 78) = 19230.77 bps. This is a relative err of 30.77 / 19200 = +1.6 10-3 0.16 %. Most serial communication equipment can cope with relative baud rate errs of up to 6 %. This relative err should always be kept as small as possible. Control registers SCIxCR1 and SCIxCR2 specify all other parameters of the interface, e.g. the number of bits per data wd (8/9), the type of parity checking (even/odd/none), whether the reception/transmission complete interrupts are enabled, whether the receiver/transmitter is enabled, etc. (see: Figure LMP6-3). Figure LMP6-3 Serial communication start bit, data, stop bit The status registers can be used to check the current state of the interface when waiting f incoming data (Receive Data Register Full RDRF) and/ pri to initiating a data transmission (Transmit Data Register Empty TDRE). There are also flags that indicate the end of a transmission (Transmission Complete TC) as well as various err conditions, e.g. when the Receive Data Register is overwritten by new incoming data befe the program has managed to read the previous value (Overrun OR), etc. There are two SCI Data Registers, SCIxDRH and SCIxDRL. Regular 8-bit communication only makes use of SCIxDRL. Implementation Write a serial communication module f SCI1 (e.g. SCI1.c ), including the following functions: char SCI1_Init(unsigned long baudrate) SCI1_OutChar(char mychar) SCI1_InChar() SCI1_OutString(char *mystring) SCI1_InString(char *mystring, unsigned int maxlength) All functions are to be expted as external in a cresponding header file SCI1.h. The string functions should make call upon the character functions to transmit/receive the individual characters. Function SCI1_InString receives a pointer to a buffer of length maxlength. The function should never accept me data as there is space on this buffer; all received characters are to be echoed back to the sending host (commonly a terminal program). If you are keen, you could catch non-printable characters such as backspace and delete the arrows and move the curs accdingly. Write a main module which calls upon the functions of your new serial communications module to read strings from a terminal connected to the serial connect P2 on the Dragon12 board. Set the communication speed to 115200 bps with 8 data bits and no parity checking. The program should then echo back whatever the user has typed on 4

the terminal befe waiting f the next input (infinite loop). Figure LMP6-4 shows a screen shot of what the output of this program could look like. Figure LMP6-4 Output of the test program; SCI1 runs at 115200 Extensions [1] Write communication routines which read and write signed and unsigned decimal numbers as well as signed and unsigned hexadecimal numbers: unsigned int signed int SCI1_InUnsignedDec() SCI1_InSignedDec() and unsigned int signed int SCI1_InUnsignedHex() SCI1_InSignedHex() [2] Modify SCI1.c to implement interrupt driven background communication as shown in class. An elegant version of this program would make use of ring buffers the macros introduced in lecture MP7 are fairly generic and should also run on the MC9S12. 5