Using the Z8 Encore! XP Timer

Similar documents
Generating DTMF Tones Using Z8 Encore! MCU

Using Z8 Encore! XP MCU for RMS Calculation

Electric Bike BLDC Hub Motor Control Using the Z8FMC1600 MCU

DTMF Signal Detection Using Z8 Encore! XP F64xx Series MCUs

Technique for Measuring System Temperature Using the On-chip Temperature Sensor of the Z8 Encore! XP

Crystal Oscillator/Resonator Guidelines for ez80 and ez80acclaim! Devices

Topics Introduction to Microprocessors

A Unipolar Stepper Motor Drive Using the Z8 Encore! MCU

LP3943/LP3944 as a GPIO Expander

8253 functions ( General overview )

AN3332 Application note

ZNEO Z16F Series. High Performance Microcontrollers. Product Specification PS PRELIMINARY

Microprocessor & Interfacing Lecture Programmable Interval Timer

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

ZKit-51-RD2, 8051 Development Kit

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

AN4507 Application note

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

MICROCONTROLLER TUTORIAL II TIMERS

LM4: The timer unit of the MC9S12DP256B/C

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

NuMicro N76E003 Brushless DC Motor Control User Manual

CSCI1600 Lab 4: Sound

Project Final Report: Directional Remote Control

16-Bit Hardware Pulse Width Modulator Data Sheet

Unit-6 PROGRAMMABLE INTERRUPT CONTROLLERS 8259A-PROGRAMMABLE INTERRUPT CONTROLLER (PIC) INTRODUCTION

UM0791 User manual. Demonstration firmware for the DMX-512 communication protocol receiver based on the STM32F103Zx. Introduction

EE 314 Spring 2003 Microprocessor Systems

M16C/26 APPLICATION NOTE. Using The M16C/26 Timer in PWM Mode. 1.0 Abstract. 2.0 Introduction

AN2581 Application note

EIE/ENE 334 Microprocessors

XGATE Library: PWM Driver Generating flexible PWM signals on GPIO pins

Microcontrollers and Interfacing

Lab 5 Timer Module PWM ReadMeFirst

For reference only Refer to the latest documents for details

High Resolution Pulse Generation

General-Purpose OTP MCU with 14 I/O LInes

Measuring Distance Using Sound

Low Energy Timer. AN Application Note. Introduction

ME 333 Assignment 7 and 8 PI Control of LED/Phototransistor Pair. Overview

µtasker Document µtasker Hardware Timers

AN4379 Application note

M16C/26 APPLICATION NOTE. Using Timer A in One-Shot Mode. 1.0 Abstract. 2.0 Introduction

AN2979 Application note

Real Time Embedded Systems. Lecture 1 January 17, 2012

AN3252 Application note

Fixed-function (FF) implementation for PSoC 3 and PSoC 5LP devices

CS/ECE/EEE/INSTR F241 MICROPROCESSOR PROGRAMMING & INTERFACING MODULE 8: I/O INTERFACING QUESTIONS ANUPAMA KR BITS, PILANI KK BIRLA GOA CAMPUS

FlexTimer and ADC Synchronization

Counter/Timers in the Mega8

Z8 OTP MCU with Infrared Timers

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

MM58174A Microprocessor-Compatible Real-Time Clock

FR FAMILY MB91460 PULSE FREQUENCY MODULATOR 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

AN2424 Application note

F²MC-8FX/16LX/16FX/FR FAMILY BLDC DRIVE WITH THE PPG

CE PSoC 6 MCU Breathing LED using Smart IO

Grundlagen Microcontroller Counter/Timer. Günther Gridling Bettina Weiss

ECE251: Tuesday October 3 0

ATmega16A Microcontroller

Microcontroller: Timers, ADC

Temperature Monitoring and Fan Control with Platform Manager 2

Table 1: Cross Reference of Applicable Products. INTERNAL PIC NUMBER Arm Cortex M0+ UT32M0R PWM Module QS30

BLDC Motor Control on Z8FMC16 Series MCUs Using Sensored Sinusoidal PWM Modulation

Chapter 6 PROGRAMMING THE TIMERS

EVDP610 IXDP610 Digital PWM Controller IC Evaluation Board

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

PWM System. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Fixed-function (FF) implementation for PSoC 3 and PSoC 5 devices

PCA bit I 2 C LED driver with programmable blink rates INTEGRATED CIRCUITS May 05. Product data Supersedes data of 2003 Feb 20

AN0026.1: EFM32 and EFR32 Wireless SOC Series 1 Low Energy Timer

GTM-IP. Application Note AN012 ATOM Flexible PWM generation. Date: (Released ) Robert Bosch GmbH Automotive Electronics (AE)

AN1449 Application note

PAK-VIIIa Pulse Coprocessor Data Sheet by AWC

EE445L Fall 2011 Quiz 2A Page 1 of 6

ANLAN203. KSZ84xx GPIO Pin Output Functionality. Introduction. Overview of GPIO and TOU

Z86116 CMOS Z8 PN MODULATOR WIRELESS CONTROLLER CUSTOMER PROCUREMENT SPECIFICATION FEATURES GENERAL DESCRIPTION Z86116 CP95WRL0501 PRELIMINARY

AN Programming the PCA200x family of watch ICs. Document information

Brian Hanna Meteor IP 2007 Microcontroller

Successive approximation (capacitive coupling amplifier)

AN0026.0: EFM32 and EZR32 Wireless MCU Series 0 Low Energy Timer

Universal Driver Software User Guide FP-GPIO96 FeaturePak 96-bit digital I/O module For Version and later

VORAGO Timer (TIM) subsystem application note

Lazy Clock Electronics and Software

Iowa State University Electrical and Computer Engineering. E E 452. Electric Machines and Power Electronic Drives

The Need. Reliable, repeatable, stable time base. Memory Access. Interval/Event timers ADC DAC

AN4014 Application Note Adjustable LED blinking frequency using a potentiometer and STM8SVLDISCOVERY Application overview

Portland State University MICROCONTROLLERS

AN4062 Application note

RL78 Motor Control. YRMCKITRL78G14 Starter Kit. Renesas Electronics Europe. David Parsons Application Engineering Industrial Business Group.

ZIO Python API. Tutorial. 1.1, May 2009

PWMLib PWM Library. Jim Schimpf. Document Number: PAN Revision Number: April Pandora Products. 215 Uschak Road Derry, PA 15627

10-Bit A/D Converter: Example of Settings for Conversion in Single Mode

AN4277 Application note

PCL-836 Multifunction countertimer and digital I/O add-on card for PC/XT/ AT and compatibles

AVR1311: Using the XMEGA Timer/Counter Extensions. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Safety Mechanism Implementation for Motor Applications in Automotive Microcontroller

ECED3204: Microprocessor Part IV--Timer Function

Four Quadrant Speed Control of DC Motor with the Help of AT89S52 Microcontroller

Transcription:

Application Note Using the Z8 Encore! XP Timer AN013104-1207 Abstract Zilog s Z8 Encore! XP microcontroller consists of four 16-bit reloadable timers that can be used for timing, event counting or for generating pulsewidth modulation (PWM) signals. This Application Note highlights the Z8 Encore! XP Timer functionality and provides a set of routines to use the Timer in different modes, such as the ONE-SHOT, CONTINUOUS, COUNTER, PWM, CAPTURE, COMPARE, GATED, and the CAPTURE/COMPARE modes. The Timer functionality is configured through API functions that initialize, enable, disable, reload, start and reset the Timer, and set the PWM, Timer interrupt priority and Timer output. Note: The source code file associated with this Application Note, AN0131- SC01.zip is available for download on www.zilog.com. Z8 Encore! XP Flash MCU Overview Zilog s Z8 Encore! XP products are based on the new ez8 CPU and introduce Flash memory to Zilog s extensive line of 8-bit microcontrollers. Flash memory in-circuit programming capability allows for faster development time and program changes in the field. The high-performance register-to-register based architecture of the ez8 core maintains backward compatibility with Zilog s popular Z8 microcontroller unit (MCU). Featuring ez8 CPU, the new Z8 Encore! XP microcontrollers combine a 20 MHz core with Flash memory, linear-register SRAM, and an extensive array of on-chip peripherals. These peripherals make the Z8 Encore! XP suitable for a variety of applications including motor control, security systems, home appliances, personal electronic devices, and sensors. Overview of Timers Timers are useful in a variety of day-to-day applications. They can be used to maintain an accurate time-of-day clock, set an alarm to turn OFF after some elapsed time, measure elapsed time between two externally occurring events, count moving objects on a conveyor belt or, generate a melody or a DTMF dialing, etc. In control system applications, Timers can be used to perform tasks at regular intervals, like event captures, and generation of events and pulses of different frequencies with varying duty cycles. Timers can be on-chip (that is, hardware implemented) or can be implemented in software. With software, Timers can be implemented using forloops or counters. However, such timing depends on the number and type of instructions, which may not make efficient use of the CPU as it prevents the CPU from working on other useful processing activity. It is desirable to free the CPU to perform other useful activities while waiting for an amount of time to elapse, rather than spend it in a do-nothing loop. Microprocessors and microcontrollers usually come with one or more on-chip Timers that can be used in different operating modes. The Z8 Encore! XP Timer operating modes are described in the Z8 Encore! XP Timer Operation on page 2. Copyright 2007 by Zilog, Inc. All rights reserved. www.zilog.com

Z8 Encore! XP Timer Features There are four 16-bit, reloadable Z8 Encore! XP Timers that can be used for timing, event counting, or for generating pulse-width modulated signals. The features of Z8 Encore! XP Timer s include: 16-bit, reload counter Programmable prescaler with prescale values from 1 to 128 PWM output generation Capture, compare and capture/compare capability External input pin for Timer input, clock gating, or capture signal Timer output pin Timer interrupt Figure 1 displays the Z8 Encore! XP Timer architecture. Data Bus Timer Control Timer Block Block Control System Clock Timer Input Gate Input Capture Input 16-Bit Reload Register 16-Bit Counter with Prescaler 16-Bit PWM/Compare Compare Compare Interrupt, PWM and Timer Output Control Timer Interrupt Timer Output Figure 1. Architecture of the Z8 Encore! XP Timer Z8 Encore! XP Timer Operation Z8 Encore! XP Timers are 16-bit, up-counter timers. Table 1 consists of the reload, prescale, and duration values that can be set for the smallest and largest time-out delays. Table 1. Timer Values for Type of Time-Out Delays Type of Time-Out Delay Timer Reload Values Prescale Values Duration = (Prescale Value Clock Period) * Timer Reload Value Smallest 0001H 1 Duration = 1 system clock frequency period Largest 0000H 128 Duration = system clock frequency period * 128 * 65536 Note: When the Timer reaches a value of FFFFH, it rolls over to 0000H and continues counting. AN013104-1207 Page 2 of 16

Z8 Encore! XP Timer Modes Z8 Encore! XP Timers can be configured to operate in the following modes. CONTINUOUS Mode In the CONTINUOUS mode, the time-out period is determined by the following equation: CONTINUOUS Mode time-out period( s) In this mode, the counter resets to 0001 after reaching the reload value and then resumes counting. Figure 2 displays the output and the interrupt generated during CONTINUOUS mode of operation. = Reload Value Prescale -------------------------------------------------------------- System clock frequency( Hz) Output Interrupt Figure 2. Output Generated in CONTINUOUS Mode CONTINUOUS mode can generate a square wave that can develop any real time clock application. However, it is not limited to such applications. ONE-SHOT Mode In the ONE-SHOT mode, the time-out period is determined by the following equation: ONE-SHOT Mode time-out period( s) In this mode, the reload counter resets to 0001 after reaching the reload value and the Timer is disabled automatically. The ONE-SHOT operating mode can generate a delayed trigger pulse. COUNTER Mode In the COUNTER mode, the number of Timer input transitions that occur from start of the Timer is determined by the following equation: = ( Reload Value Start Value) Prescale ---------------------------------------------------------------------------------------- System clock frequency( Hz) COUNTER Mode Timer Input Transitions = Current Count Value Start Value AN013104-1207 Page 3 of 16

In this mode, the counter counts the external events up to the reload value, then resets to 0001 and resumes counting. Figure 3 displays the output generated during counter operating mode. Input Output Figure 3. Output Generated in COUNTER Mode The COUNTER mode counts external pulses/ events. The input to the Timer is an external pulse. PWM Mode The PWM period is determined by the following equation: PWM period( s) = Reload Value Prescale -------------------------------------------------------------- System clock frequency( Hz) If TPOL (a control bit that selects the port I/O polarity in the timer control register) is set to 0, the ratio of the PWM Output High Time to the total period is calculated by the following equation: PWM Output High Time Ratio (%) = Reload Value PWM Value 100 ----------------------------------------------------------------------------------------- Reload Value Note: The PWM value must be less than the reload value. If TPOL is set to 1, the ratio of the PWM Output High Time to the total period is calculated by the following equation: PWM Output High Time Ratio (%) PWM Value 100 ----------------------------------------------- Reload Value Figure 4 displays the output generated during PWM mode of operation. = Output Figure 4. Output Generated In PWM Mode AN013104-1207 Page 4 of 16

The PWM mode is widely used in control system applications. For example, in the Servo control system, changing the duty cycle of the PWM pulse can change the speed of the motor. CAPTURE Mode In the CAPTURE mode, the elapsed time from Timer Start to Timer Capture events can be calculated by the following equation: Capture Elapsed Time( s) The CAPTURE mode can be used to calculate the time interval between two successive events, which can be used to develop a time interval meter. COMPARE Mode In the COMPARE mode, the input signal is continuously compared with a dynamic specified event such that it throws an interrupt whenever the values match. The Timer resumes counting after it is reset. The Compare time is determined by the following equation: ( Capture Value Start Value) Prescale = ----------------------------------------------------------------------------------------------------------- System clock frequency( Hz) COMPARE Mode Time( s) = ( Compare Value Start Value) Prescale --------------------------------------------------------------------------------------------------------------- System clock frequency( Hz) Figure 5 displays the output and interrupt generated during the COMPARE operating mode. Compare output Interrupt Figure 5. Output Generated In COMPARE Mode AN013104-1207 Page 5 of 16

GATED Mode In the GATED mode, the timer counts only when the timer input signal is in its active state. When the timer reaches the reload value, it resets to 0001H and resumes counting. Also, if the timer output alternate function is enabled, the Timer output pin changes state at timer reset.the input to the Timer in this mode is the gating pulse. This mode can be used for measuring the ON/OFF time, which in turn can be used to measure the frequency of the gated input pulse. CAPTURE/COMPARE Mode In the CAPTURE/COMPARE mode, the elapsed time from Timer Start to Timer Capture events can be calculated by the following equation: Capture Elapsed Time( s) ( Capture Value Start Value) Prescale = -------------------------------------------------------------------------------------------------------------- System clock frequency( Hz) Z8 Encore! XP Register Descriptions The Z8 Encore! XP Timer registers are briefly described in this section. There are four Timer registers. Timer Control Register (TxCTL) The Timer Control Register (TxCTL) selects the TIMER mode, sets the prescale value, defines the polarity of input/output pulse and disables/enables the timer. Table 2 displays the Timer Control Register. Table 2. Timer Control Register (TxCTL) BITS 7 6 5 4 3 2 1 0 FIELD RESET TEN TPOL PRES TMODE TEN Timer Enable TPOL Timer Polarity PRES Prescale value TMODE TIMER Mode 0 0 0 0 0 0 0 0 AN013104-1207 Page 6 of 16

Timer Byte Register (TxH, TxL) The Timer Byte Register (TxH, TxL) provides a delay in the first cycle count of the timer after the timer is activated. Table 3 displays the Timer High Byte Register and Table 4 displays the Timer Low Byte Register. Table 3. Timer High Byte Register (TxH) BITS 7 6 5 4 3 2 1 0 TH FIELD 0 0 0 0 0 0 0 0 RESET TH Start Timer High value Table 4. Timer Low Byte Register (TxL) BITS FIELD RESET TL Start Timer Low value 7 6 5 4 3 2 1 0 TL 0 0 0 0 0 0 0 1 Timer Reload Register (TxRH, TxRL) The Timer Reload Register (TxRH, TxRL) loads the terminal count of the timer. The pulse period depends on the register value. Table 5 displays the Timer Reload High Byte Register and Table 6 displays the Timer Reload Low Byte Register. Table 5. Timer Reload High Byte Register (TxRH) BITS 7 6 5 4 3 2 1 0 FIELD TRH RESET 1 1 1 1 1 1 1 1 TRH Timer Reload High value AN013104-1207 Page 7 of 16

Table 6. Timer Reload Low Byte Register (TxRL) BITS 7 6 5 4 3 2 1 0 FIELD TRL RESET 1 1 1 1 1 1 1 1 TRL Timer Reload Low value Timer PWM Byte Register (TxPWMH, TxPWML) The Timer PWM Byte Register (TxPWMH, TxP- WML) modulates the width in a given pulse period. The duty cycle of the modulated pulse is directly proportional to the value of the register.table 7 displays the Timer PWM High Byte Register and Table 8 displays the Timer PWM Low Byte Register. Table 7. Timer PWM High Byte Register (TxPWMH) BITS 7 6 5 4 3 2 1 0 FIELD PWMH RESET 0 0 0 0 0 0 0 0 PWMH PWM High value Table 8. Timer PWM Low Byte Register (TxPWML) BITS 7 6 5 4 3 2 1 0 FIELD PWML RESET 0 0 0 0 0 0 0 0 PWML PWM Low value AN013104-1207 Page 8 of 16

Using the Z8 Encore! XP Timer The Z8 Encore! XP Timer is configured using the APIs described in this application note. There are ten APIs that perform the following tasks: 1. Initialize the Timer 2. Enable Timer 3. Disable Timer 4. Set Timer control 5. Start the Timer 6. Reload the Timer 7. Set the PWM value for the Timer in PWM mode 8. Set the Timer priority 9. Set the Timer output 10. Reset the Timer The init_timer() API is used to initialize the Z8 Encore! XP Timer in different modes. All the other APIs are called within this API, during initialization. The following examples describes the usage of the init_timer() API. For more information on description of this API, see Appendix B API Description on page 14. init_timer() void init_timer(timer_num, timer_cont, s_high, s_low, r_high, r_low, pm_high, pm_low) Example 1 Consider the example where you need to configure a Timer, TIMER0, in a CONTINUOUS mode to generate 1 ms pulses. Follow the steps below to achieve this configuration: 1. Disable TIMER0 2. Set the mode in CONTINUOUS mode and timer number to TIMER0 3. Set the timer start value to 0x0000 4. Set the timer reload value to 0x4800 5. Set the timer priority 6. Enable TIMER0 All the above tasks is accomplished by calling the init_timer()api and entering the required parameters, as displayed below. main() { init_timer(timer0,continuous_m ODE,0x00,0x00,0x48,0x00,0x00,0 x00); /*call the function to display the real time clock*/ } Follow the steps below in the interrupt routine to update the real time clock: isr_timer0() { static int sec_timer = 0; if(sec_timer++ > 1000) /*call a function to increment the real time clock*/ } Example 2 Follow the steps below to generate a PWM signal: 1. Disable the TIMER1 2. Set the mode in PWM mode and timer number to TIMER1 3. Set the timer start value to 0x0000 4. Set the timer reload value to 0x4800 (500 Hz) 5. Set the timer PWM value to 0x1200 (25%) 6. Set the timer priority 7. Enable TIMER1 AN013104-1207 Page 9 of 16

All these operations is accomplished by calling the init_timer() API and entering the required parameters as displayed below. main() { init_timer(timer1,pwm_mode,0x0 0,0x00,0x48,0x00,0x12,0x00); } Example 3 Follow the steps below to change the duty cycle of the PWM pulse for the timer (Timer#), with the new PWM values as high value and low value: 1. Disable the timer, Timer# 2. Set the timer PWM values, high value and low value 3. Enable the timer, Timer# To perform this operation, the following three APIs are called in the sequence given below: { } disable_timer(timer#); set_timer_pwm(timer#,high value,low value); enable_timer(timer#); Testing the Z8 Encore! XP Timer in Different Modes The API routines developed for Z8 Encore! XP Timer are tested for different modes. Figure 6 displays the setup to test the Timer functionality in different modes. The function generator generates the required input for the Timer. The Logic Analyzer/CRO captures the timer output. Function Generator (Aplab 2 MHz) Trigger Input Z8F6403 MCU A/F pin Logic Analyzer (HP 1661A) or Port pin CRO (Tektronix 2465A 350 MHz) Figure 6. Setup to Test TIMER Mode Functionality The function generator is used in the modes where external input is required, such as the COUNTER, CAPTURE, and the CAPTURE/COMPARE modes. For testing the ONE-SHOT mode, one pulse is generated just before enabling the Timer, and the second pulse is generated in the interrupt service routine (ISR) of the Timer. Figure 7 through Figure 9 display the Timer output waveforms, at the appropriate Port pins, for different timer configurations. AN013104-1207 Page 10 of 16

Figure 7. CONTINUOUS Mode Waveform Figure 8. COUNTER Mode Waveform AN013104-1207 Page 11 of 16

Figure 9. PWM Mode Waveform Summary There are different methods to configure the Z8 Encore! XP Timers to operate in different modes, for different applications. This Application Note provides a set of routines that offer a ready-to-use solution to configure the Z8 Encore! XP Timer dynamically for all modes, so that product design time and cost is reduced. The solution provided in this Application Note can be used for, but is not limited to, developing products like real-time clocks, PWM generation, timing generation, and a host of other timer applications. References The documents associated with ez8 CPU and Z8 Encore! XP available on www.zilog.com are provided below: ez8 CPU Core User Manual (UM0128) Z8 Encore! Flash Microcontroller Development Kit User Manual (UM0146) Z8 Encore! XP 64K Series Flash Microcontrollers Product Specification (PS0199) AN013104-1207 Page 12 of 16

Appendix A Flowcharts This Appendix displays the flowchart to configure the Z8 Encore! XP Timer (see Figure 10). START -Disable timer -Configure the timer in the specified mode -Set the prescale value, initial logic level Write to the Timer High and Low Byte registers to set the starting count value Write to the timer reload high and low byte registers to set the starting count value Write to the timer PWM high and low byte registers to set the starting count value. -This is valid in PWM mode only Enable the timer interrupt and set the timer interrupt priority Configure the GPIO port pin for the timer output alternate function Enable the timer and initiate counting END Figure 10. Flowchart to Configure the Timers AN013104-1207 Page 13 of 16

Appendix B API Description This Appendix contains the detailed description of the init_timer() API. init_timer() Prototype void init_timer(timer_num, timer_cont, s_high, s_low, r_high, r_low, pm_high, pm_low); Description This API initializes all the on-chip timer parameters for required functionality. The timer_cont parameter s variables are defined before the function is called. The timer_cont parameter is expressed as: Argument (s) unsigned char timer_control = enable_disable polarity prescale timer_mode; Return Value (s) Example 1 timer_num timer_cont s_high, s_low r_high, r_low: 0 for Timer0. To set the Timer for CONTINUOUS Mode This parameter defines the TIMER mode, disables/enables the timer, sets the prescale value and polarity. Sets the desired timer start value. Sets the desired timer reload value. pm_high, pm_low Sets the desired PWM value. This argument is valid for PWM mode only. Nil init_timer(0, timer_control, 00, 00, 48, 00, 00, 00) timer_cont = DISABLE_TIMER POLARITY_HIGH PRESCL_1 CONTINU- OUS; This API invokes Timer0 for CONTINUOUS mode of operation. The output pulse width is 1 ms. DISABLE_TIMER, POLARITY_HIGH, PRESCL_1, and CONTINUOUS are # defined in the program. AN013104-1207 Page 14 of 16

Example 2 To set the Timer for PWM mode with High Polarity. init_timer(1, timer_control, 00, 00, 48, 00, 12, 00) timer_control = DISABLE_TIMER POLARITY_HIGH PRESCL_1 PWM; This API invokes Timer1 for PWM mode of operation. The PWM pulse width is 250 µs. DISABLE_TIMER, POLARITY_HIGH, PRESCL_1, and PWM are # defined in the program. Example 3 To set the Timer for PWM Mode with Low Polarity init_timer(1, timer_control, 00, 00, 48, 00, 12, 00) timer_control = DISABLE_TIMER POLARITY_LOW PRESCL_1 PWM; This API invokes Timer1 for PWM mode of operation. Polarity Low inverts the out pulse. In this case, the PWM pulse width is 750 µs. DISABLE_TIMER, POLARITY_LOW, PRESCL_1, and PWM are # defined in the program. Example 4 To set the Timer for SINGLE-SHOT/ONE-SHOT mode init_timer(2, timer_control, 00, 00, 48, 00, 00, 00) timer_control = DISABLE_TIMER POLARITY_HIGH PRESCL_1 ONE_SHOT; This API invokes Timer2 for SINGLE-SHOT mode of operation. Interrupts are generated after 1 ms. DISABLE_TIMER, POLARITY_HIGH, PRESCL_1, and ONE_SHOT are # defined in the program. AN013104-1207 Page 15 of 16

Warning: DO NOT USE IN LIFE SUPPORT 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 2007 by 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 registered trademarks of Zilog, Inc. All other product or service names are the property of their respective owners. AN013104-1207 Page 16 of 16