A Simple Console Application for Z8 Encore! XP MCUs

Similar documents
Flash Loader Utility for the Z8 Encore! XP MCU

Boot Loader for the Z51F6412 MCU

High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers

Using the Z8051 MCU s USI Peripheral as an SPI Interface

ez80f91 Modular Development Kit

Z8 Encore! XP F0822 Series

Getting Started with ESPI Interface Using the Z8 Encore! XP F1680

EEPROM Emulation with the ez80f91 MCU. Discussion

ZMOTION Detection Module Development Kit

An Automatic Temperature Control System Using RZK

Z8 Encore! XP/Z8 Encore! Development Kits

Challenge. Hardware Circuit Details. Solution. Result. Features and Functions. Z8 Encore! MC

Zilog TCP/IP Software Suite

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

Ethernet Smart Cable

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

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

S3F8S5A Development Kit

S3 Flash In-System Programmer

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals

Universal Motor Control with Z8 Encore! XP 8-Pin Highly Integrated Microcontroller

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

High-Performance 8-Bit Microcontrollers. Up to 8 10-Bit ADC Channels. Two 16-Bit Timers/PWM. Internal Precision Oscillator

Zilog Real-Time Kernel

5x7 LED Matrix Display with Z8 Encore! XP

Implementing a Secure Digital Card with a ZNEO Microcontroller

Set Up a PLL Loop Filter on the ez80f91 MCU

Character LCD Interface for ez80acclaim! MCUs

Z8 Encore! XP 4K Series with extended Peripherals

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

ez80190 Development Kit Quick Start Guide

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

ZLF645 Crimzon Flash Microcontroller with ZBase Database Industry Leading Universal Infrared Remote Control (UIR) Solution

C8051F530A-DK C8051F530A DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents

AC/DC. Adapter. Ribbon. Cable Serial. Serial. Adapter. Figure 1. Hardware Setup using an EC2 Serial Adapter

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Z8 Encore! XP Family of Microcontrollers Development Kits

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Z8 Encore! XP F0822 Series Development Kit

STEPPER-MOTOR-RD STEPPER MOTOR REFERENCE DESIGN KIT USER S GUIDE. 1. Kit Contents. 2. Kit Overview. Figure 1. Stepper Motor Reference Design Board

SKP16C26 Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

Quick Start Guide TWR-S08PT60. 5-Volt S08P Family of 8-bit MCUs for Industrial and Appliance Applications TOWER SYSTEM

Z8 Encore! Z8F642 MCU Evaluation Kit

AC/DC. Adapter. Serial. Adapter. Figure 1. Hardware Setup

Old Company Name in Catalogs and Other Documents

C8051F700-DK C8051F700 DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Hardware Setup

XC2000 Family AP Application Note. Microcontrollers. XC2236N Drive Card Description V1.0,

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

Debugging in AVR32 Studio

CodeWarrior Development Studio for Freescale 68HC12/HCS12/HCS12X/XGATE Microcontrollers Quick Start SYSTEM REQUIREMENTS Hardware Operating System 200

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

XE166 Family AP Application Note. Microcontrollers. X E D r i v e C a r d H a r d w a r e D e s c r i p t i o n Board REV.

AN5181. Building a thermometer using the STM8 Nucleo-64 boards. Application note. Introduction

Objective: Additional project details: Code: PSEMBP 100 Category:STEM Level: High School/Community C.

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

SENSORLESS-BLDC-MOTOR-RD

Serial Communication Controllers (SCC) MULTIPROTOCOL DATA COMMUNICATION SOLUTIONS

Also available for purchase separately are socket daughter boards for the QFN-11 and QFN-10 packages.

M16C/62P QSK QSK62P Plus Tutorial 1. Software Development Process using HEW4

Zatara Series ARM ASSP High-Performance 32-bit Solution for Secure Transactions

Easy Kit Board Manual

Old Company Name in Catalogs and Other Documents

1. Opening the sample code workspace Loading the selected sample code project and Opening sample code source files... 5

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

Nuvoton 4T 8051-based Microcontroller NuTiny-SDK-N78E715 User Manual

AN10955 Full-duplex software UART for LPC111x and LPC13xx

C8051F00x/01x-DK C8051F00X/01X DEVELOPMENT KIT USER S GUIDE. 1. Kit Contents. 2. Hardware Setup using a USB Debug Adapter

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup Using a USB Debug Adapter

AC/DC Adapter. Figure 1. Hardware Setup

EVBQE128. Evaluation Board for Freescale Flexis QE128. User s Manual

M16C R8C FoUSB/UART Debugger. User Manual REJ10J

Evaluation board for NXP LPC2103. User Guide. Preliminary Version updated 27 th Aug TechToys Company All Rights Reserved

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

C8051F36x-DK. C8051F36x DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Hardware Setup Using a USB Debug Adapter

Controller Continuum. for Microcontrollers V6.3. Quick Start

Old Company Name in Catalogs and Other Documents

Digital UART Product Specification

USB Debug. Adapter USB DEBUG ADAPTER. J4 Silicon Laboratories. Stop Power. Run AC/DC. Adapter. Figure 1. Hardware Setup Using a USB Debug Adapter

XE166 Family AP Application Note. Microcontrollers. UConnect XE162N Hardware Description V1.0,

Nuvoton 1T 8051-based Microcontroller NuTiny-SDK-N76E885 User Manual

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

SENSORLESS-BLDC-MOTOR-RD

Quick-Start Guide. BNS Solutions. QSK62P Plus

C8051F800-DK C8051F800 DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Hardware Setup

Micrel Serial Programmer (MICUSB)

Lab Tutorial for TWR-S08GW64 TOWER SYSTEM. MC9S08GW64 LCD segment MCU for flow meters and energy metering applications

keyestudio Keyestudio MEGA 2560 R3 Board

C8051F580DK C8051F580 DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Getting Started

C8051F411-EK C8051F411 EVALUATION KIT USER S GUIDE. 1. Kit Contents. 2. Kit Overview. 3. Evaluation Board Interface LCD User Interface

Copyright mikroelektronika, All rights reserved.

Lab 1 Introduction to Microcontroller

UM0792 User manual. Demonstration firmware for the DMX-512 communication protocol transmitter based on the STM32F103Zx.

LPC2148 DEV BOARD. User Manual.

F28335 ControlCard Lab1

Quick Start Guide TWR-S08DC-PT60. Tower System Daughter Card for the 5-Volt 8-bit MC9S08P Family TOWER SYSTEM

RS232 Relay Board-R242. User Manual. Jan 2012 Doc-R242-UM-Rev1.0 iknowvations.in

Transcription:

A Simple Console Application for Z8 Encore! XP MCUs AN034201-1112 Abstract Console applications are widely used by engineers for ease of project development. For this reason, Zilog has developed a simple console application to allow customers to not only quickly develop their projects, but to provide a simple UI application that employs a common industry command set. Using these commands, developers can enable GPIO as input and output, turn devices on using a relay, or read sensors via the ADC input pin. The Z8 Encore! XP console application described in this document has been created to occupy a very small footprint (below 3 KB) to allow other customer-developed applications to fit into MCU memory. The command set for this application is discussed in the Software Implementation section on page 6. This console application offers the following features: Less than 3 KB total footprint HyperTerminal connection for commands and responses Commonly-used industry command set Input and output pin control ADC control Note: The source code file associated with this application note, AN0342-SC01.zip, is available for download from the Zilog website. It has been tested with ZDS II for Z8 Encore! version 5.0.0. Discussion A console application is a line command-based program that is used to control the peripherals units of an MCU. These commands are keyed in using a keyboard, and the Hyper- Terminal emulation program displays the results of these commands and their responses. The Z8 Encore! XP Console Application is written in the C language and can be downloaded to any of Zilog s Z8 Encore! XP MCUs. This application will accept a line command and return an appropriate response; its command set comprises a simple command and a narrow range of parameters. After the MCU has executed a command, a response message will be returned to the HyperTerminal console, where the response can be seen as a value or a return message. AN034201-1112 Page 1 of 16

Commands and Responses The Z8 Encore! XP Console Application Command Set consists of only eight commands. These commands, listed in Table 1, are each described in this section. Table 1. Console Application Command Set SET CLR GET ADC CBR RST CON? Note: The Z8 Encore! XP Console Application Command Set is not case-sensitive. SET The SET command is used to pull the corresponding [PORT][PIN] to a logic High, which equates to the MCU voltage supply. Parameters SET [PORT][PIN] [PORT] = PA:PH; [PIN] = 0:7. Syntax SET<SPACE>[PORT][PIN]<ENTER KEY> Example COMMAND RESPONSE SET PA1 OK! CLR The CLR command is used to pull the corresponding [PORT][PIN] to a logic Low. Parameters CLR [PORT][PIN] [PORT] = PA:PH; [PIN] = 0:7 Syntax CLR<SPACE>[PORT][PIN] <ENTER KEY> AN034201-1112 Page 2 of 16

Example COMMAND RESPONSE CLR PA1 OK! GET The GET command is used to get the value of [PORT][PIN]. Parameters GET [PORT][PIN] [PORT] = PA:PH; [PIN] = 0:7 Syntax GET<SPACE>[PORT][PIN] <ENTER KEY> Example COMMAND GET PA1 RESPONSE 1 or 0 CON The CON command is used to cause a corresponding [PORT][PIN] to be either an input or an output. If [DIRECTION] is equal to 1, then PIN is an input; if [DIRECTION] is equal to 0, then PIN is an output. Parameters [PORT], [PIN], [DIRECTION] Syntax CON<SPACE>[PORT][PIN][DIRECTION] <ENTER KEY> Example COMMAND RESPONSE CON PA10 OK! Note: As the syntax in the above example shows, there is no space between the [PIN] and [DIRECTION] values. ADC The ADC command is used to get the ADC value of AN[PARAM]. AN034201-1112 Page 3 of 16

Parameters [PARAM] [PARAM] is 0:7 Syntax ADC<SPACE>[PARAM] <ENTER KEY> Example COMMAND ADC 0 RESPONSE ANA0=xxxx Note: Not all ADC commands are available with each Z8 Encore XP! MCU. See Table 5 on page 15, which lists the Z8 Encore XP! parts pertinent to this application and their available ADC commands. CBR The CBR command is used to change the baud rate of the UART peripheral. These baud rates are represented by [PARAM] as indicated in Table 2; the default baud rate is 56 kbps. Table 2. CBR Command: Baud Rate Parameter Values Parameter Value Baud Rate (bps) 0 9600 1 19200 2 38400 3 57600 4 115200 Parameter [PARAM] Syntax CBR<SPACE> [PARAM] <ENTER KEY> Example COMMAND CBR 0 RESPONSE OK! AN034201-1112 Page 4 of 16

RST Issuing the RST command executes a system reset to the MCU. Parameters None. Syntax RST<ENTER KEY> Example COMMAND RESPONSE RST OK!? The? command is used to display a list of commands. Parameters None. Syntax? <ENTER KEY> Example COMMAND? Description RESPONSE SET CLR GET CON ADC CBR RST? Set port pin Clear port pin Get port pin status Configure port pin Get ADC value Change baud rate Reset Show list of commands Note: If a command not listed in Table 1 on page 2 is entered, or if a command is entered incorrectly, the application will return Error!. AN034201-1112 Page 5 of 16

Hardware Implementation This console application was implemented using the Z8F6423, Z8F1680, Z8F0822, and Z8F082A development boards, with serial connections as shown in Figure 1. A serial cable is used to connect these development boards to a PC using HyperTerminal. Figure 1. A Serially-Connected Z8F64xx Development Board Software Implementation The source code was written in C and the routines were modularized for users to copy and use in their their application requirements. At code initialization, only UART0 is configured, with a baud rate of 56 kbps. The Hyper- Terminal console will display the message, Zilog Console Application v1.0, as shown in Figure 2. AN034201-1112 Page 6 of 16

Figure 2. HyperTerminal Window Displaying Zilog Console Application v1.0 Users can enter a command and press the Enter key for command execution. The console application accepts the command while waiting for the command terminator ( 0x0A) to be received; this command terminator indicates the end of a command message. When this 0x0A value has been received, the console application will process the command message, which is divided into three parts: the Command, the Separator (0x20) and the Parameter. After processing the command, the console application will return a message indicating either values or a status. Table 3 lists the functions and macros of the console application. Table 3. Console Functions and Macros Function void get_input(void) void reset_board(void) void read_adc(unsigned char pin_number) Description Accepts user input. Resets the board. Reads the ADC value of a give pin_number. AN034201-1112 Page 7 of 16

Table 3. Console Functions and Macros (Continued) Function void get_input(void) void init_uart0(unsigned char baud) #define help() void gpio_bit(unsigned char casenum,unsigned char *c) Description Accepts user input. Changes the baud rate of the UART0 to the entered parameter, as follows: Baud Parameter Index 0: 9600 1: 19200 2: 38400 3: 57600 4: 115200 Displays a list of commands. Performs the specific process indicated by case number (0) CON, (1) CLR, (2) SET and (3) GET). Equipment Used The tools used to create and test this application are: ZDS II Z8 Encore! v5.0.0 Z8 Encore! XP MCUs: Z8F6423 Z8F1680 Z8F0822 Z8F082A 5 V DC power supply Serial cable Testing/Demonstrating the Application This section discusses a methodology for demonstrating this application and testing its software. Hardware Setup Figure 1 on page 6 highlights the test elements on the Z8F64xx Development Board. The LEDs illuminate when the I/O pin are set to High or Low, and the BUTTON switch is used to indicate a GPIO High or Low condition. The VARIABLE RESISTOR is used to vary the ADC input voltages. AN034201-1112 Page 8 of 16

Software Configuration After the hardware is correctly configured, observe the following procedure to correctly compile, load and run the software. 1. Launch HyperTerminal by clicking the Windows Start button at the lower left of your desktop and entering Run to open the Command Prompt. Enter hypertrm.exe into the Command Prompt and press the Enter key on your keyboard. The Connection Description dialog box will appear. 2. Enter any name you prefer into the Name: field and click OK. The COM1 Properties dialog box will appear. In this dialog, ensure that HyperTerminal is configured to match the values shown in Figure 3, then click OK. Figure 3. HyperTerminal Settings 3. Download ZDS II Z8 Encore! v5.0.0 and follow the prompts as they guide you through the ZDS II installation. 1. Download the AN0342-SC01.zip file from the Zilog website and unzip it to your PC s hard drive. 2. Launch the ZDS II IDE. AN034201-1112 Page 9 of 16

3. From the File menu in ZDS II, select Open Project to display the Open dialog box. In this dialog, browse to and open the AN0342-SC01 folder, find the AN0342.zdsproj file, and click Open to open the project. 4. From the Project menu, select Settings... to open the Project Settings dialog. In the left panel of this dialog, click Code Generation. In this Code Generation panel, ensure that the checkbox labeled Limit Optimizations for Easier Debugging is deselected and that Memory Model: is set to Large. 5. In the left panel, click Debugger. In the Target pane, select the AN0342_Z8F6423 project by clicking its checkbox. 6. In this same Debugger window, click the Setup button, which is just below the Target pane. A small dialog box labeled Configure Target -- AN0342_Z8F6423 will appear. In this dialog, ensure that the Clock Frequency is set to the 20 (MHz) value. Additionally, ensure that the crystal oscillator on your development board is a 20 MHz crystal. Click OK. 7. A dialog box will appear, displaying the following message: The project settings have changed since the last build. Would you like to rebuild the affected files? Click the Yes button to rebuild the project. 8. In the ZDS II main window, select Go from the Debug menu to step through the debug process. Alternatively, click the Go icon ( ) in the ZDS II toolbar, or press F5 on your keyboard. Note: If ZDS II should indicate that No USB Smart Cable has been detected, ensure that the USB Smart Cable is properly connected to the PC. AN034201-1112 Page 10 of 16

9. In a moment, the HyperTerminal window will appear, as seen in Figure 2 on page 7. Figure 4. HyperTerminal Displaying A List Of Commands 10. Enter any command in its proper format, as discussed in the Software Implementation section on page 6. Results Using the SET and CLR commands in HyperTerminal, the Z8 Encore! XP MCU s GPIOs were configured as outputs that illuminated the LED on the Z8F6423 Development Board. Using the GET and CON commands, these GPIOs were configured as inputs to get the status of a switch attached to the input pin (whether logic High or Low). Using the ADC command, the software read the ADC value to get the voltage level of the potentiometer in the analog input pin. With the CBR command, the baud rate was successfully changed to a preferred rate. AN034201-1112 Page 11 of 16

Summary References This document discusses a simple console application for Z8 Encore! XP microcontrollers. The application can turn a specific I/O pin as input or output, make it Low or High, and read I/O pin status if Low or High. Additionally, the application can read the voltage level of the ADC I/O pin. The following documents are associated to Zilog s Z8 Encore! XP series of MCUs and are available free for download from the Zilog website. Z8 Encore! XP F64xx Series Product Specification (PS0199) Z8 Encore! XP F1680 Series Product Specification (PS0250) Z8 Encore! XP F0823 Series Product Specification (PS0243) Z8 Encore! XP F082A Series Product Specification (PS0228) AN034201-1112 Page 12 of 16

Appendix A. Flowcharts Figure 5 shows the flow of the main application. Start Initialize all components Print Welcome note Command was received? No Yes Process command End Figure 5. The Main Software Flow AN034201-1112 Page 13 of 16

Appendix B. Commands The syntax of each of the Z8 Encore! XP Console Application Command Set s eight commands, and their responses in HyperTerminal, are listed in Table 4. Table 4. Commands and Responses Command Response Description SET<SPACE>[PORT][PIN]<ENTER KEY> OK! Set specific port pin. CLR<SPACE>[PORT][PIN][DIRECTION]<ENTER KEY> OK! Clear specific port pin. CON<SPACE>[PORT][PIN]<ENTER KEY> OK! Configure specific port pin as input or output. GET<SPACE>[PORT][PIN]<ENTER KEY> 1 or 0 Get the status of a specific port pin. ADC<SPACE>[PARAM]<ENTER KEY> AN[PARAM]=xxx Read the voltage level at a specific analog pin. CBR<SPACE>[PARAM]<ENTER KEY> OK! Change the UART0 baud rate. RST<ENTER KEY> OK! Reset the MCU.?<ENTER KEY> SET Set port pin List all commands. CLR Clear port pin GET Get port pin status CON Configure port pin ADC Get ADC value CBR Change baud rate RST Reset? Show a list of commands AN034201-1112 Page 14 of 16

Appendix C. ADC Commands Analog Input Table 5 shows the analog inputs for each of the Z8 Encore! XP MCUs, indicated by part number. Table 5. ADC Commands Z8 Encore! XP MCU Part Number 80-Pin Z8F642x 28-Pin Z8F1680 28-Pin Z8F082x 28-Pin Z8F082A ADC0 ADC1 ADC2 ADC3 ADC4 ADC5 ADC6 ADC7 AN034201-1112 Page 15 of 16

Customer Support To share comments, get your technical questions answered, or report issues you may be experiencing with our products, please visit Zilog s Technical Support page at http://support.zilog.com. To learn more about this product, find additional documentation, or to discover other facets about Zilog product offerings, please visit the Zilog Knowledge Base at http:// zilog.com/kb or consider participating in the Zilog Forum at http://zilog.com/forum. This publication is subject to replacement by a later edition. To determine whether a later edition exists, please visit the Zilog website at http://www.zilog.com. Warning: DO NOT USE THIS PRODUCT IN LIFE SUPPORT SYSTEMS. LIFE SUPPORT POLICY ZILOG S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION. As used herein Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b) support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a significant injury to the user. A critical component is any component in a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system or to affect its safety or effectiveness. Document Disclaimer 2012 Zilog, Inc. All rights reserved. Information in this publication concerning the devices, applications, or technology described is intended to suggest possible uses and may be superseded. ZILOG, INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT. ZILOG ALSO DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE. The information contained within this document has been verified according to the general principles of electrical and mechanical engineering. Z8, Z8 Encore! and Z8 Encore! XP are trademarks or registered trademarks of Zilog, Inc. All other product or service names are the property of their respective owners. AN034201-1112 Page 16 of 16