Using the Z8 Encore! Timer

Size: px
Start display at page:

Download "Using the Z8 Encore! Timer"

Transcription

1 Using the Z8 Encore! Timer ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA Telephone: Fax:

2 This publication is subject to replacement by a later edition. To determine whether a later edition exists, or to request copies of publications, contact: ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA Telephone: Fax: ZiLOG and Z8Encore! are registered trademarks of ZiLOG Inc. in the United States and in other countries. All other products and/or service names mentioned herein may be trademarks of the companies with which they are associated. Information Integrity The information contained within this document has been verified according to the general principles of electrical and mechanical engineering. Any applicable source code illustrated in the document was either written by an authorized ZiLOG employee or licensed consultant. Permission to use these codes in any form, besides the intended application, must be approved through a license agreement between both parties. ZiLOG will not be responsible for any code(s) used beyond the intended application. Contact the local ZiLOG Sales Office to obtain necessary license agreements. Document Disclaimer 2003 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. Except with the express written approval ZiLOG, use of information, devices, or technology as critical components of life support systems is not authorized. No licenses or other rights are conveyed, implicitly or otherwise, by this document under any intellectual property rights.

3 iii Table of Contents List of Figures iv List of Tables v Abstract Z8 Encore! Flash MCU Overview Overview of Timers Z8 Encore! Timer Features Z8 Encore! Timer Operation Z8 Encore! Register Descriptions Using the Z8 Encore! Timer Testing the Z8 Encore! Timer in Different Modes Summary Appendix A Reference Appendix B Flowcharts Appendix C Source Code C Files Header Files Appendix D API Description Table of Contents

4 iv List of Figures Figure 1. Architecture of the Z8 Encore! Timer Figure 2. Setup to Test Timer Mode Functionality Figure 3. Continuous Mode Waveform Figure 4. Counter Mode Waveform Figure 5. PWM Mode Waveform Figure 6. Flowchart to Configure the Timers List of Figures

5 v List of Tables Table 1. Timer Values for Type of Time-Out Delays Table 2. Timer Control Register (TxCTL) Table 3. Timer High Byte Register (TxH) Table 4. Timer Low Byte Register (TxL) Table 5. Timer Reload High Byte Register (TxRH) Table 6. Timer Reload Low Byte Register (TxRL) Table 7. Timer PWM High Byte Register (TxPWMH) Table 8. Timer PWM Low Byte Register (TxPWML) Table 9. List of References List of Tables

6 1 Abstract The Z8 Encore! microcontroller contains four 16-bit reloadable timers that can be used for timing, event counting or for generating pulse-width modulation (PWM) signals. This Application Note highlights the Z8 Encore! 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 pulse-width modulation, Timer interrupt priority and Timer output. The AN0131-SC01.zip file, available on the ZilOG website, contains the source code for this Application Note. Z8 Encore! Flash MCU Overview ZiLOG s Z8 Encore! 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 MCU. Featuring ZiLOG s ez8 CPU, the new Z8 Encore! microcontrollers combine a 20MHz core with Flash memory, linear-register SRAM, and an extensive array of on-chip peripherals. These peripherals make the Z8 Encore! 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 go 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, and so on. In control system applications, timers can be used to perform tasks at regular intervals, like event captures, and generation of events & 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 for-loops 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 Abstract

7 2 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! Timer operating modes are described in the Z8 Encore! Timer Operation section on page 3. Z8 Encore! Timer Features There are four 16-bit, reloadable Z8 Encore! Timers that can be used for timing, event counting, or for generating pulse-width modulated (PWM) signals. The Z8 Encore! Timer s features 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 depicts the Z8 Encore! Timer architecture. Timer Block Data Bus Timer Control 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! Timer Z8 Encore! Timer Features

8 3 Z8 Encore! Timer Operation Z8 Encore! Timers are 16-bit, up-counter timers. Table 1 contains the reload, prescale and duration values that can be set for the smallest and largest time-out delays. Type of Time- Out Delay Table 1. Timer Values for Type of Time-Out Delays Timer Reload Values Prescale Values Duration = ( Prescale Value Clock Period ) * Timer Reload Value Smallest 0001H 1 = 1 system clock frequency period Largest 0000H 128 = system clock frequency period * 128 * Note: When the Timer reaches a value of FFFFH, it rolls over to 0000H and continues counting. Z8 Encore! Timer Modes Z8 Encore! Timers can be configured to operate in different modes. The equations used to calculate the required parameters for each mode are described below. For details, refer to Z8 Encore! Product Specification documentation (PS0176, PS0197, PS0199) available on the ZiLOG website. Continuous Mode In the Continuous mode, the time-out period is determined by the following equation: Continuous Mode time-out period(s) = Reload value x Prescale System clock frequency (Hz) In this mode, the counter resets to 0001 after reaching the reload value and then resumes counting. A pictorial representation of the output and the interrupt generated during continuous mode of operation is illustrated below. Output Interrupt Continuous mode can generate a square wave that can develop any real time clock application. However, it is not limited to such applications. Z8 Encore! Timer Operation

9 4 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) = (Reload Value Start Value) x Prescale System Clock Frequency (Hz) 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: Counter Mode Timer Input Transitions = Current Count Value Start Value In this mode, the counter counts the external events up to the reload value, then resets to 0001 and resumes counting. A pictorial representation of the output generated during counter operating mode is illustrated below. Input Output 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) Z8 Encore! Timer Operation

10 5 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 as follows: PWM Output High Time Ratio (%) = Reload Value - PWM Value x 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 as follows: PWM Output High Time Ratio (%) = PWM Value x 100 Reload Value A pictorial representation of the output generated during PWM mode of operation is illustrated below. Output The PWM mode is widely used in control system applications. For instance, 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 using the following equation: Capture Elapsed Time (s) = (Capture Value Start Value) Prescale System Clock Frequency (Hz) 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. Z8 Encore! Timer Operation

11 6 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: Compare Mode Time (s) = (Compare Value Start Value) Prescale System Clock Frequency (Hz) A pictorial representation of the output and interrupt generated during the Compare operating mode is illustrated below. Compare output Interrupt 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 using the following equation: Capture Elapsed Time (s) = (Capture Value Start Value ) Prescale System Clock Frequency (Hz) Z8 Encore! Timer Operation

12 7 Z8 Encore! Register Descriptions The Z8 Encore! Timer registers are briefly described in this section. There are four Timer registers. 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 illustrates the Timer Control Register. TEN-Timer Enable TPOL-Timer Polarity PRES-Prescale value Table 2. Timer Control Register (TxCTL) BITS FIELD TEN TPOL PRES TMODE RESET TMODE-Timer Mode Timer Byte Register (TxH, TxL). Provides a delay in the first cycle count of the timer after the timer is activated. Table 3 illustrates the Timer High Byte Register. Table 3. Timer High Byte Register (TxH) BITS FIELD TH RESET TH-Start Timer High value Table 4 illustrates the Timer Low Byte Register. Table 4. Timer Low Byte Register (TxL) BITS FIELD TL RESET TL-Start Timer Low value Z8 Encore! Register Descriptions

13 8 Timer Reload Register (TxRH, TxRL). Loads the terminal count of the timer. The pulse period depends on the register value. Table 5 illustrates the Timer Reload High Byte Register. Table 5. Timer Reload High Byte Register (TxRH) BITS FIELD TRH RESET TRH-Timer Reload High value Table 6 illustrates the Timer Reload Low Byte Register. Table 6. Timer Reload Low Byte Register (TxRL) BITS FIELD TRL RESET TRL-Timer Reload Low value Timer PWM Byte Register (TxPWMH, TxPWML). 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 illustrates the Timer PWM High Byte Register. Table 7. Timer PWM High Byte Register (TxPWMH) BITS FIELD PWMH RESET PWMH-PWM High value Table 8 illustrates the Timer PWM Low Byte Register. Z8 Encore! Register Descriptions

14 9 Table 8. Timer PWM Low Byte Register (TxPWML) BITS FIELD PWML RESET PWML-PWM Low value The Z8 Encore! Timer is configured using the APIs provided with this Application Note. There are ten APIs to perform the tasks listed below: 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 Appendix C on page 17 contains the code for these APIs. The init_timer() API is used to initialize the Z8 Encore! Timer in different modes. All of the other APIs are called within this API, during initialization. The examples presented below showcase how the init_timer() API is used. Appendix D on page 37 contains a full description of this API along with more usecases. init_timer() void init_timer(timer_num, timer_cont, s_high, s_low, r_high, r_low, pm_high, pm_low) Example 1 Using the Z8 Encore! Timer

15 10 Consider a case where you need to configure a timer, TIMER0, in a continuous mode, to generate 1msec pulses. To achieve this configuration, the following operations are required to be performed: 1. Disable TIMER0 2. Set the mode in continuous mode and timer number to TIMER0 3. Set the timer start value to 0x Set the timer reload value to 0x Set the timer priority 6. Enable TIMER0 All of the above tasks is accomplished by calling the API, init_timer() and entering the required parameters, as illustrated below. main() init_timer(timer0,continuous_mode,0x00,0x00, 0x48,0x00,0x00,0x00); call the function to display the real time clock To update the real time clock, the following operations are performed in the interrupt routine: isr_timer0() static int sec_timer = 0; if(sec_timer++ > 1000) call a function to increment the real time clock Example 2 To generate a PWM signal, the following operations are performed: 1. Disable the TIMER1 2. Set the mode in PWM mode and timer number to TIMER1 3. Set the timer start value to 0x 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 Using the Z8 Encore! Timer

16 11 Again, all these operations is accomplished by calling the init_timer() API and entering the required parameters as illustrated below. main() init_timer(timer1,pwm_mode,0x00,0x00,0x48,0x00, 0x12,0x00); Example 3 Assume that you want to change the duty cycle of the PWM pulse for the timer (Timer#), with the new PWM values as high value and low value. The following operations are performed: 1. Disable the timer, Timer# 2. Set the timer PWM values, high value and low value 3. Enable the timer, Timer# For such an operation, three of the 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! Timer in Different Modes The API routines developed for Z8 Encore! Timer were tested for different modes. Figure 2 illustrates 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. Testing the Z8 Encore! Timer in Different Modes

17 12. 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 2. Setup to Test Timer Mode Functionality The function generator is used in those 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 ISR of the Timer. The Timer output waveforms, at the appropriate Port pins, for different timer configurations are shown in the Figures 3, 4 and 5. Figure 3. Continuous Mode Waveform Testing the Z8 Encore! Timer in Different Modes

18 13 Figure 4. Counter Mode Waveform Figure 5. PWM Mode Waveform Testing the Z8 Encore! Timer in Different Modes

19 14 Summary There are several ways to configure the Z8 Encore! 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! 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. Summary

20 15 Appendix A Reference Further details aboutez8 CPU and Z8 Encore! MCU can be found in the references listed in Table 9. Table 9. List of References Topic ez8 CPU Z8 Encore! MCU Document Name ez8 CPU User Manual (UM0128) Z8 Encore! Microcontrollers with Flash Memory and 10-bit A/D Converter Product Specification (PS0176) Z8 Encore! Flash Microcontroller Developer Kit User Manual (UM0131) Appendix A Reference

21 16 Appendix B Flowcharts This appendix contains the flowcharts for the Z8 Encore! Timer implementation. Figure 6 illustrates the flowchart to configure the Z8 Encore! Timers. 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 6. Flowchart to Configure the Timers Appendix B Flowcharts

22 17 Appendix C Source Code This appendix provides listing of source code associated with this Application Note. The source code file AN0131-SC01.zip is available on the ZiLOG website. C Files The following C files are listed in this section: main.c API.c interrupt.c * * File: main.c * Description: This file contains the variable for initializing the timer. * This is the only file which interacts with the user. * * Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED. * * The source code in this file was written by an * authorized ZiLOG employee or a licensed consultant. * The source code has been verified to the fullest * extent possible. * * Permission to use this code is granted on a royalty-free * basis. However users are cautioned to authenticate the * code contained herein. * * ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE. * Project:Using Z8Encore! Timer in different modes Module: Main Purpose: This file contains the variables to configure the timer. This is the only file that interacts with the user. Dependencies: #include <ez8.h> #include "API.h" History: Appendix C Source Code

23 18 Date Action Created References: Document Number Title um0128.pdf ez8 CPU User Manual um0130.pdf Z8ENZDS0200ZCC ZiLOG Developer Studio II-- Z8 Encore! TM User Manual ps0176.pdf Z8 Encore! TM Microcontrollers with Flash Memory and 10-Bit A/D Converter Product Specification #include <ez8.h> #include "API.h" unsigned char timer_no = TIMER_0; TIMER_1, unsigned char timer_mode = ONE_SHOT; unsigned char prescale = PRESCL_1; unsigned char polarity = POLARITY_HIGH; unsigned char enable_disable = DISABLE_TIMER; unsigned char start_high = 0x00; unsigned char start_low = 0x00; unsigned char reload_high = 0x48; unsigned char reload_low = 0x00; unsigned char pwm_high = 0x12; unsigned char pwm_low = 0x00; // Select timer TIMER_0, // TIMER_2, TIMER_3 // Select timer mode // ONE_SHOT,CONTINUOUS, // COUNTER,PWM, // CAPTURE,COMPARE,GATED, // CAPTURE_COMPARE // Select prescale PRESCL_1, // PRESCL_2,PRESCL_3, // PRESCL_4,PRESCL_5,PRESCL_6, // PRESCL_7,PRESCL_8 // Select polarity // POLARITY_HIGH/POLARITY_LOW // Select timer DISABLE_TIMER/ // ENABLE_TIMER // timer start value from // 0x0000 to 0xFFFF // timer reload value from // 0x0001 to 0xFFFF // timer PWM value from 0x0001 // to 0xFFFF Routine: main Appendix C C Files

24 19 Parameters: None Return: Nothing Purpose: This function is the base routine for this system. main () unsigned char timer_control = enable_disable polarity prescale timer_mode; // this information will go to // timer control register init_timer(timer_no, timer_control, start_high, start_low, reload_high, reload_low, pwm_high, pwm_low); //timer initialization API EI(); while(1) ; End of File * File: API.c * Description: This file contains the timer APIs * * Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED. * * The source code in this file was written by an * authorized ZiLOG employee or a licensed consultant. * The source code has been verified to the fullest * extent possible. * * Permission to use this code is granted on a royalty-free * basis. However users are cautioned to authenticate the Appendix C C Files

25 20 * code contained herein. * * ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE. Project: Using Z8Encore! Timer in different modes Module: API Purpose: The purpose of this file is to provide the routines to configure the timer registers Dependencies: #include <ez8.h> #include "API.h" #include "interrupt.h" #include "gpio.h" History: Date Action Created References: Document Number Title um0128.pdf ez8 CPU User Manual um0130.pdf Z8ENZDS0200ZCC ZiLOG Developer Studio II-- Z8 Encore! TM User Manual ps0176.pdf Z8 Encore! TM Microcontrollers with Flash Memory and 10-Bit A/D Converter Product Specification #include <ez8.h> #include "API.h" #include "interrupt.h" #include "gpio.h" Routine: set_timer_control Parameters: timer_no, timer_control Return: Nothing Purpose: This function sets the timer mode, prescale,output polarity Appendix C C Files

26 21 void set_timer_control(unsigned char timer_no, unsigned char timer_control) switch(timer_no) case 0: T0CTL = timer_control; case 1: T1CTL = timer_control; case 2: T2CTL = timer_control; case 3: T3CTL = timer_control; Routine: enable_timer Parameters: timer_no Return: Nothing Purpose: This function enables the timer void enable_timer(unsigned char timer_no) switch(timer_no) case 0: T0CTL = 0x80; case 1: T1CTL = 0x80; case 2: T2CTL = 0x80; case 3: // Put On T0 // Put On T1 // Put On T2 Appendix C C Files

27 22 T3CTL = 0x80; // Put On T3 Routine: disable_timer Parameters:timer_no Return: Nothing Purpose: This function disables the timer This function disables the timer void disable_timer(unsigned char timer_no) switch(timer_no) case 0: T0CTL &= 0x7F; // Put off T0 case 1: T1CTL &= 0x7F; // Put off T1 case 2: T2CTL &= 0x7F; // Put off T2 case 3: T3CTL &= 0x7F; // Put off T3 Routine: start_timer Parameters: timer_no, start_high, start_low Return: Nothing Purpose: This function sets the starting value of the timer Appendix C C Files

28 23 void start_timer(unsigned char timer_no, unsigned char start_high, unsigned char start_low) switch(timer_no) case 0: T0H = start_high; T0L = start_low; case 1: T1H = start_high; T1L = start_low; case 2: T2H = start_high; T2L = start_low; case 3: T3H = start_high; T3L = start_low; Routine: reload_timer Parameters: timer_no, rload_high, rload_low Return: Nothing Purpose: This function sets the reload value of the timer void reload_timer(unsigned char timer_no, unsigned char rload_high, unsigned char rload_low) switch(timer_no) case 0: T0RH = rload_high; T0RL = rload_low; case 1: Appendix C C Files

29 24 case 2: case 3: T1RH = rload_high; T1RL = rload_low; T2RH = rload_high; T2RL = rload_low; T3RH = rload_high; T3RL = rload_low; Routine: set_timer_pwm Parameters: timer_no, pwm_high, pwm_low Return: Nothing Purpose: This function sets the PWM value of the timer void set_timer_pwm(unsigned char timer_no, unsigned char pwm_high, unsigned char pwm_low) switch(timer_no) case 0: T0PWMH = pwm_high; T0PWML = pwm_low; case 1: T1PWMH = pwm_high; T1PWML = pwm_low; case 2: T2PWMH = pwm_high; T2PWML = pwm_low; case 3: T3PWMH = pwm_high; T3PWML = pwm_low; Appendix C C Files

30 25 Routine: set_timer_priority Parameters: timer_no, Return: Nothing Purpose: This function sets the priority value of the timer void set_timer_priority(unsigned char timer_no) switch(timer_no) case 0: SET_VECTOR(TIMER0, isr_timer0); IRQ0ENH = 0xFF; IRQ0ENL = 0x20; // high priority case 1: SET_VECTOR(TIMER1, isr_timer1); IRQ0ENH = 0xFF; IRQ0ENL = 0x40; // high priority case 2: case 3: SET_VECTOR(TIMER2, isr_timer2); IRQ0ENH = 0xFF; IRQ0ENL = 0x80; // high priority SET_VECTOR(TIMER3, isr_timer3); IRQ2ENH = 0xFF; IRQ2ENL = 0x80; // high priority Routine: set_timer_output Parameters: timer_no, Return: Nothing Purpose: This function sets the gpio pin in alternate function Appendix C C Files

31 26 void set_timer_output(unsigned char timer_no) switch(timer_no) case 0: PAADDR = ALT_FUN; PACTL = 0x03; case 1: case 2: PCADDR = ALT_FUN; PCCTL = 0x03; PCADDR = ALT_FUN; PCCTL = 0xC0; case 3: PDADDR = ALT_FUN; PDCTL = 0x03; Routine: reset_timer Parameters: timer_no, Return: Nothing Purpose: This function configures all timer registers to its reset value void reset_timer(unsigned char timer_no) switch(timer_no) case 0: T0H = 0x00; T0L = 0x00; T0RH = 0xFF; Appendix C C Files

32 27 T0RL = 0xFF; T0PWMH = 0x00; T0PWML = 0x00; T0CTL = 0x00; case 1: T1H = 0x00; T1L = 0x00; T1RH = 0xFF; T1RL = 0xFF; T1PWMH = 0x00; T1PWML = 0x00; T1CTL = 0x00; case 2: T2H = 0x00; T2L = 0x00; T2RH = 0xFF; T2RL = 0xFF; T2PWMH = 0x00; T2PWML = 0x00; T2CTL = 0x00; case 3: T3H = 0x00; T3L = 0x00; T3RH = 0xFF; T3RL = 0xFF; T3PWMH = 0x00; T3PWML = 0x00; T3CTL = 0x00; Routine: init_timer Parameters: timer_num, timer_cont, s_high, s_low, r_high, r_low, pm_high, pm_low Appendix C C Files

33 28 Return: Nothing Purpose: The timer initialization function is used to configure the timer void init_timer(unsigned char timer_num, unsigned char timer_cont, unsigned char s_high, unsigned char s_low, unsigned char r_high, unsigned char r_low, unsigned char pm_high, unsigned char pm_low) // int i; //for testing // init_port(); //for testing disable_timer(timer_num);//timer disable set_timer_control(timer_num, timer_cont); //select the timer mode start_timer(timer_num, s_high, s_low); //load the timer start count value TxH, TxL from (0000-FFFF) reload_timer(timer_num, r_high, r_low); //load the timer reload count value TxRH, TxRL from (0000-FFFF) if((timer_cont & PWM)== PWM) set_timer_pwm(timer_num, pm_high, pm_low); //Timer PWM initialization set_timer_priority(timer_num); //Timer interrupt priority selection set_timer_output(timer_num); // PHOUT=0x01; //for testing // for(i=0;i<40;i++) //for testing // ; //for testing // PHOUT=0x00; //for testing enable_timer(timer_num);//timer enable End of File * File: interrupt.c Appendix C C Files

34 29 * Description: This file contains the timer ISRs * * Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED. * * The source code in this file was written by an * authorized ZiLOG employee or a licensed consultant. * The source code has been verified to the fullest * extent possible. * * Permission to use this code is granted on a royalty-free * basis. However users are cautioned to authenticate the * code contained herein. * * ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE. * Project: Using Z8Encore! Timer in different modes Module: interrupt Purpose: This file contains the ISR routines for all timers Dependencies: #include <ez8.h> #include "API.h" #include "interrupt.h" History: Date Action Created References: Document Number Title um0128.pdf ez8 CPU User Manual um0130.pdf Z8ENZDS0200ZCC ZiLOG Developer Studio II-- Z8 Encore TM User Manual ps0176.pdf Z8 Encore TM Microcontrollers with Flash Memory and 10-Bit A/D Converter Product Specification #include <ez8.h> #include "API.h" #include "interrupt.h" Appendix C C Files

35 30 Routine: isr_timer0 Parameters: Nothing Return: Nothing Purpose: interrupt routine for timer0 #pragma interrupt void isr_timer0(void) int i; unsigned char timer_no = 0; unsigned char data_out_h; unsigned char data_out_l; PHOUT=0x00; data_out_h = T0PWMH; data_out_l = T0PWML; PFOUT = data_out_h; PGOUT = data_out_l; PFOD = data_out_h; PGOD = data_out_l; PHOUT=0x01; for(i=0;i<10;i++) ; PHOUT=0x00; Routine: isr_timer1 Parameters: Nothing Return: Nothing Purpose: interrupt routine for timer1 #pragma interrupt Appendix C C Files

36 31 void isr_timer1(void) ; Routine: isr_timer2 Parameters: Nothing Return: Nothing Purpose: interrupt routine for timer2 #pragma interrupt void isr_timer2(void) ; Routine: isr_timer3 Parameters: Nothing Return: Nothing Purpose: interrupt routine for timer3 #pragma interrupt void isr_timer3(void) ; End of File Appendix C C Files

37 32 Header Files The following header files are listed in this section: API.h interrupt.h * File: API.h * Description: This file contains the function prototype and definitions * * Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED. * * The source code in this file was written by an * authorized ZiLOG employee or a licensed consultant. * The source code has been verified to the fullest * extent possible. * * Permission to use this code is granted on a royalty-free * basis. However users are cautioned to authenticate the * code contained herein. * * ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE. Project: Using Z8Encore! Timer in different modes Module: API Purpose: This file is used for definitions and prototype functions History: Date Action Created References: Document Number Title um0128.pdf ez8 CPU User Manual um0130.pdf Z8ENZDS0200ZCC ZiLOG Developer Studio II-- Z8 Encore TM User Manual ps0176.pdf Z8 Encore TM Microcontrollers with Flash Memory and 10-Bit A/D Converter Product Specification Appendix C Header Files

38 33 Declaration definitions // Port initialization definitions #define DATA_DIR 0x01 #define ALT_FUN 0x02 #define OUT_CTL 0x03 //Timer number #define TIMER_0 #define TIMER_1 #define TIMER_2 #define TIMER_3 // Timer mode #define ONE_SHOT #define CONTINUOUS #define COUNTER #define PWM #define CAPTURE #define COMPARE #define GATED #define CAPTURE_COMPARE // timer prescale value #define PRESCL_1 #define PRESCL_2 #define PRESCL_3 #define PRESCL_4 #define PRESCL_5 #define PRESCL_6 #define PRESCL_7 #define PRESCL_8 0x00 0x01 0x02 0x03 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x00 0x08 0x10 0x18 0x20 0x28 0x30 0x38 // timer alternate pin polarity #define POLARITY_HIGH 0x00 //Pole 0x00 or 0x40 #define POLARITY_LOW 0x40 // timer enable and disable #define DISABLE_TIMER #define ENABLE_TIMER 0x00 0x80 //xxxxxxxx (TxCTL-Register) // _ _ Appendix C Header Files

39 34 // Timer mode(000-one shot mode, 001-Continuous mode, 010-Counter //mode, 011- PWM mode // 100-Capture mode, 101-compare mode, 110-Gated mode, //111-Capture/Compare mode). // Prescale value(000-divide by 1, 001-Divide by 2, 010-Divide by 4, //011-Divide by 8, // 100-Divide by 16, 101-Divide by 32, 110-Divide by 64, 111-Divide by //128). // Timer I/O polarity. // Timer enable (0-timer disabled, 1-timer enable) * Timer function APIs prototype * void set_timer_control(unsigned char timer_no, unsigned char timer_control); void enable_timer(unsigned char timer_no); void disable_timer(unsigned char timer_no); void start_timer(unsigned char timer_no, unsigned char start_high, unsigned char start_low); void reload_timer(unsigned char timer_no, unsigned char RLOAD_H, unsigned char RLOAD_L); void set_timer_pwm(unsigned char timer_no, unsigned char PWM_HIGH, unsigned char PWM_LOW); void set_timer_priority(unsigned char timer_no); void set_timer_output(unsigned char timer_no); void reset_timer(unsigned char timer_no); void init_timer(unsigned char timer_num, unsigned char timer_cont, unsigned char s_high, unsigned char s_low, unsigned char r_high, unsigned char r_low, unsigned char pm_high, unsigned char pm_low); End of File Appendix C Header Files

40 35 / * File: interrupt.h * Description: This file contains the function prototype * * Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED. * * The source code in this file was written by an * authorized ZiLOG employee or a licensed consultant. * The source code has been verified to the fullest * extent possible. * * Permission to use this code is granted on a royalty-free * basis. However users are cautioned to authenticate the * code contained herein. * * ZiLOG DOES NOT GUARANTEE THE VERACITY OF THE SOFTWARE. * Project: Using Z8Encore! Timer in different modes Module: interrupt Purpose: This file is used for definitions and prototype functions History: Date Action Created References: Document Number Title um0128.pdf ez8 CPU User Manual um0130.pdf Z8ENZDS0200ZCC ZiLOG Developer Studio II-- Z8 Encore TM User Manual ps0176.pdf Z8 Encore TM Microcontrollers with Flash Memory and 10-Bit A/D Converter Product Specification Timer ISR function prototype Appendix C Header Files

41 36 void isr_timer0(void); void isr_timer1(void); void isr_timer2(void); void isr_timer3(void); End of File Appendix C Header Files

42 37 Appendix D API Description This appendix contains the detailed description of the init_timer() API. init_timer() 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: unsigned char timer_control = enable_disable polarity prescale timer_mode; Parameters timer_num 0 for timer 0. timer_cont s_high, s_low r_high, r_low: pm_high, pm_low 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 sets the desired PWM value. This argument is valid for PWM mode only Return Nil Usage Example 1: To set the Timer for Continuous Mode init_timer(0, timer_control, 00, 00, 48, 00, 00, 00) timer_cont = DISABLE_TIMER POLARITY_HIGH PRESCL_1 CONTINU- OUS; Appendix D API Description

43 38 This API invokes timer 0 for continuous mode of operation. The output pulse width is 1ms. DISABLE_TIMER, POLARITY_HIGH, PRESCL_1, and CONTINUOUS are # defined in the program. 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 timer 1 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 timer 1 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 timer 2 for Single Shot mode of operation. Interrupts are generated after 1ms. DISABLE_TIMER, POLARITY_HIGH, PRESCL_1, and ONE_SHOT are # defined in the program. Appendix D API Description

Systems Programming. Lecture 11 Timers

Systems Programming.   Lecture 11 Timers Systems Programming www.atomicrhubarb.com/systems Lecture 11 Timers Section Topic Where in the books Zilog PS220 (ZNEO Z16F Series Product Specification) What is a Timer (a microcontroller timer) Timers

More information

EEPROM Emulation with the ez80f91 MCU. Discussion

EEPROM Emulation with the ez80f91 MCU. Discussion Application Note EEPROM Emulation with the ez80f91 MCU AN015803-0608 Abstract This Application Note describes a method to utilize a portion of Zilog s ez80acclaimplus! MCU s Flash memory to emulate the

More information

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

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD Application Note Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD AN014902-1207 Abstract This Application Note describes APIs for interfacing one or more I 2 C-based character LCDs with

More information

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

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later Product Update Errata to Z8 Encore! 8K Series Silicon Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later The errata listed in Table 1 are found in the Z8 Encore! 8K Series devices with date codes

More information

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

High-Performance 8-Bit Microcontrollers. Up to 8 10-Bit ADC Channels. Two 16-Bit Timers/PWM. Internal Precision Oscillator High-Performance 8-Bit Microcontrollers Z8 Encore! 4K Series QuickTime and a BMP decompressor are needed to see this picture. Product Block Diagram 1 4 KB Watch-Dog Timer with RC Oscillator Analog UART

More information

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

An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus Application Note An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus AN012703-0608 Abstract This Application Note provides an overview of Zilog s Z8 Encore! Serial Peripheral Interface (SPI)

More information

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

Getting Started with ESPI Interface Using the Z8 Encore! XP F1680 Application Note Getting Started with ESPI Interface Using the Z8 Encore! XP F1680 AN027301-0308 Abstract This application note demonstrates how to use the Enhanced Serial Peripheral Interface (ESPI) in

More information

Z8 Encore! XP 4K Series with extended Peripherals

Z8 Encore! XP 4K Series with extended Peripherals High-Performance 8-Bit Microcontrollers Z8 Encore! XP 4K Series with extended Peripherals PB013603-0604 PRELIMINARY Product Block Diagram 1 4KB Two 16-Bit Timers/PWM Watch-Dog Timer with RC Oscillator

More information

5x7 LED Matrix Display with Z8 Encore! XP

5x7 LED Matrix Display with Z8 Encore! XP Application Note 5x7 LED Matrix Display with Z8 Encore! XP AN014402 1207 Abstract This application note explains the method to use Zilog s Z8 Encore! XP microcontroller s General-Purpose Input/Output (GPIO)

More information

An Automatic Temperature Control System Using RZK

An Automatic Temperature Control System Using RZK Application Note An Automatic Temperature Control System Using RZK AN019902-0908 Abstract This application note demonstrates how an application running on Zilog s Real-Time Kernel (RZK) can be used to

More information

Z8 Encore! Z8F642 MCU Evaluation Kit

Z8 Encore! Z8F642 MCU Evaluation Kit Evaluation Kit Quick Start Guide Introduction This guide acquaints users with the Z8 Encore! Z8F642 MCU Evaluation Kit, and gives instructions on setting up and using the tools to start building designs

More information

ZiLOG Real-Time Kernel Version 1.2.0

ZiLOG Real-Time Kernel Version 1.2.0 ez80acclaim Family of Microcontrollers Version 1.2.0 PRELIMINARY Introduction The (RZK) is a realtime, preemptive, multitasking kernel designed for time-critical embedded applications. It is currently

More information

Character LCD Interface for ez80acclaim! MCUs

Character LCD Interface for ez80acclaim! MCUs Application Note Character LCD Interface for ez80acclaim! MCUs AN015902-0708 Abstract This Application Note provides Character LCD driver routines, coded in ANSI C, for Zilog s ez80acclaim! Flash microcontroller-based

More information

Flash Loader Utility for the Z8 Encore! XP MCU

Flash Loader Utility for the Z8 Encore! XP MCU Application Note Flash Loader Utility for the Z8 Encore! XP MCU AN011806-0408 Abstract This application note describes Flash Loader utility for the Zilog s Z8 Encore! XP MCU that can be operated through

More information

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

Challenge. Hardware Circuit Details. Solution. Result. Features and Functions. Z8 Encore! MC Implementation of SMBus Master/Slave Protocol Application Brief Challenge The System Management Bus (SMBus) interface is used by Smart Batteries to pass Smart Battery Data (SBD) to external devices and

More information

Z8 Encore! XP Family of Microcontrollers Development Kits

Z8 Encore! XP Family of Microcontrollers Development Kits Z8 Encore! XP Family of Microcontrollers Development Kits Introduction This describes how to set up your Z8 Encore! XP Development Kit and start using it to build designs and applications. Kit Contents

More information

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

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals Embedded Flash Solutions Z8 Encore! XP F1680 Series High-performance 8-bit Flash MCU F1680 advantage low power - 1.8 V highly integrated peripherals flexible memory options optimized cost/performance target

More information

PPG Function of F2MC-16LX MCU Series as PWM

PPG Function of F2MC-16LX MCU Series as PWM PPG Function of F2MC-16LX MCU Series as PWM Introduction... 1 PPG Function... 1 Important Register Configuration... 2 Flow chart... 3 Program Code... 4 Fujitsu Microelectronics America, Inc. i PPG Function

More information

Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 F²MC-FR FAMILY 32-BIT MICROCONTROLLER MB91460 RELOAD TIMER APPLICATION NOTE

Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 F²MC-FR FAMILY 32-BIT MICROCONTROLLER MB91460 RELOAD TIMER APPLICATION NOTE Fujitsu Microelectronics Europe Application Note MCU-AN-300060-E-V10 F²MC-FR FAMILY 32-BIT MICROCONTROLLER MB91460 RELOAD TIMER APPLICATION NOTE Revision History Revision History Date 2008-03-26 V1.0,

More information

The following article describes how to use the M16C/62 timers A s as square wave generators (Pulse Output Mode).

The following article describes how to use the M16C/62 timers A s as square wave generators (Pulse Output Mode). APPLICATION NOTE M16C/62 1.0 Abstract The following article describes how to use the M16C/62 timers A s as square wave generators (Pulse Output Mode). 2.0 Introduction The M16C/62 is a 16-bit MCU, based

More information

Interfacing a Graphic LCD with a Z8 Encore! 64K Series MCU

Interfacing a Graphic LCD with a Z8 Encore! 64K Series MCU Interfacing a Graphic LCD with a Z8 Encore! 64K Series MCU ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA 95126 Telephone: 408.558.8500 Fax: 408.558.8300 www.zilog.com This publication is subject

More information

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers 8051 Peripherals On-Chip Memory Timers Serial Port Interrupts Computer Engineering 2 2-1 8051 Timers 8051 Timers The 8051 has 2 internal 16-bit timers named Timer 0 and Timer 1 Each timer is a 16-bit counter

More information

Using programmed I/O on the M16C; and Writing an Interrupt Service Routine (ISR)

Using programmed I/O on the M16C; and Writing an Interrupt Service Routine (ISR) Tutorial 2 Basic M16C Programming 1 Introduction The goal for Tutorial 2 is to take a more in-depth look at the sample program from the previous tutorial, and make use of it as a foundation for writing

More information

ezvision 200 Television Controllers with OSD

ezvision 200 Television Controllers with OSD ezvision 200 Television Controllers with OSD Product Specification ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA 95126-3432 Telephone: 408.558.8500 Fax: 408.558.8300 www.zilog.com This publication

More information

ez80 Webserver Write your own EMAC Driver for Metro IPWorks

ez80 Webserver Write your own EMAC Driver for Metro IPWorks Write your own EMAC Driver for Metro IPWorks Technical Article Driving an Ethernet MAC The ez80 Webserver is equipped with two Ethernet Media Access Controller EMAC drivers that control the Realtek RTL8019AS

More information

Real Time Embedded Systems. Lecture 10 January 31, 2012 Interrupts

Real Time Embedded Systems.  Lecture 10 January 31, 2012 Interrupts Interrupts Real Time Embedded Systems www.atomicrhubarb.com/embedded Lecture 10 January 31, 2012 Interrupts Section Topic Where in the books Catsoulis chapter 1 (pg 10-12) Simon chapter4 Zilog UM197 (ZNEO

More information

#RRNKECVKQP0QVG. A Two s-complement Fractional Multiplier

#RRNKECVKQP0QVG. A Two s-complement Fractional Multiplier #RRNKECVKQP0QVG A Two s-complement Fractional Multiplier TABLE OF CONTENTS ABSTRACT... 3 I. General Overview... 3 DISCUSSION... 3 I. Theory of Operation... 3 II. Results of Operation... 3 SUMMARY... 3

More information

ez80190 Development Kit Quick Start Guide

ez80190 Development Kit Quick Start Guide Introduction Follow this guide to install and begin using your new ez80190 Development Kit from ZiLOG. The setup procedure guides the user through: Software installation and online registration Hardware

More information

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

ZLF645 Crimzon Flash Microcontroller with ZBase Database Industry Leading Universal Infrared Remote Control (UIR) Solution digital infrared Solutions CRIMZON ZLF645 Flash MCU uir solution with zbase database CRIMZON ZLF645 advantage 32/64 kb flash 512 b/1 kb ram crimzon z8 lxmc core ir transmission ir learning tuned ir amplifier

More information

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

High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers Application te High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers AN025404-0608 Abstract This application note describes the development and use of a Digital Weigh-Scale (DWS)

More information

16-Bit Hardware Density Modulated PWM Data Sheet

16-Bit Hardware Density Modulated PWM Data Sheet 1. 16-Bit Hardware Density Modulated PWM User Module Data Sheet 16-Bit Hardware Density Modulated PWM Data Sheet DMM16HW DMM16HW Copyright 2009 Cypress Semiconductor Corporation. All Rights Reserved. PSoC

More information

8254 is a programmable interval timer. Which is widely used in clock driven digital circuits. with out timer there will not be proper synchronization

8254 is a programmable interval timer. Which is widely used in clock driven digital circuits. with out timer there will not be proper synchronization 8254 is a programmable interval timer. Which is widely used in clock driven digital circuits. with out timer there will not be proper synchronization between two devices. So it is very useful chip. The

More information

M16C/26 APPLICATION NOTE. Using Timer B in Pulse Period/Width Measurement Mode. 1.0 Abstract. 2.0 Introduction

M16C/26 APPLICATION NOTE. Using Timer B in Pulse Period/Width Measurement Mode. 1.0 Abstract. 2.0 Introduction APPLICATION NOTE M16C/26 1.0 Abstract Measuring the frequency (1/period) or the pulse width of an input signal is useful in applications such as tachometers, DC motor control, power usage calculations,

More information

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

Objective: Additional project details: Code: PSEMBP 100 Category:STEM Level: High School/Community C. Objective: At the end of this session, you will have a fair understanding of - Z8 Encore! language tools including C compiler, assembler, linker/locator, and librarian - Instruction set simulator and disassembler

More information

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

Universal Motor Control with Z8 Encore! XP 8-Pin Highly Integrated Microcontroller Application Note Universal Motor Control with Z8 Encore! XP 8-Pin Highly Integrated Microcontroller AN050-0608 Abstract This Application Note discusses programmable speed control of a Universal Motor using

More information

S3 Flash In-System Programmer

S3 Flash In-System Programmer S3 Family of Microcontrollers S3 Flash In-System Programmer UM026604-0816 PRELIMINARY Copyright 2016 Zilog, Inc. All rights reserved. www.zilog.com ii Warning: DO NOT USE THIS PRODUCT IN LIFE SUPPORT SYSTEMS.

More information

Using the Z8051 MCU s USI Peripheral as an SPI Interface

Using the Z8051 MCU s USI Peripheral as an SPI Interface Using the Z8051 MCU s USI Peripheral as an SPI Interface AN035901-0513 Abstract This document describes how to configure Zilog s Z8051 Universal Serial Interface (USI) peripheral to operate as Serial Peripheral

More information

Z8 Encore! XP F0822 Series

Z8 Encore! XP F0822 Series High Performance 8-Bit Microcontrollers Z8 Encore! XP F0822 Series Product Brief PB011112-0308 Overview Zilog s Z8 Encore! XP F0822 Series devices are microcontrollers based on Zilog s ez8 CPU. Z8 Encore!

More information

Application Note. Synchronous Operation Mode

Application Note. Synchronous Operation Mode Application Note Synchronous Operation Mode For H8/3694 series Contact Info: Brazen Tek, Inc. 20121 Ventura Blvd. Suite 310 Woodland Hills, CA 91364 USA Tel/Fax: (818) 710-9262 E-mail: info@brazentek.com

More information

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE AVR 8-bit Microcontrollers AVR134: Real Time Clock (RTC) Using the Asynchronous Timer APPLICATION NOTE Features Real Time Clock with Very Low Power Consumption (10µA @ 3.3V) Very Low Cost Solution Adjustable

More information

M16C/26 APPLICATION NOTE. Measuring Computation Time of a Function Call. 1.0 Abstract. 2.0 Introduction. 3.0 Number of Function Call Returns

M16C/26 APPLICATION NOTE. Measuring Computation Time of a Function Call. 1.0 Abstract. 2.0 Introduction. 3.0 Number of Function Call Returns APPLICATION NOTE M16C/26 1.0 Abstract The following article discusses a technique for measuring computation time spent during a function call, which can be in C or Assembly, from a main C program for the

More information

S1C17 Family EEPROM Emulation Library Manual

S1C17 Family EEPROM Emulation Library Manual S1C17 Family EEPROM Emulation Library Manual Rev.1.1 Evaluation board/kit and Development tool important notice 1. This evaluation board/kit or development tool is designed for use for engineering evaluation,

More information

A Simple Console Application for Z8 Encore! XP MCUs

A Simple Console Application for Z8 Encore! XP MCUs 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

More information

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1

Department of EIE / Pondicherry Engineering College. Timer/Counters. Department of EIE / Pondicherry Engineering College 1 Timer/Counters Department of EIE / Pondicherry Engineering College 1 The 8051 has two internal sixteen bit hardware Timer/Counters. Each Timer/Counter can be configured in various modes, typically based

More information

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab By the end of Class Pseudo-code for Lab 1-2 due as part of prelab Homework #5 on website due before next class Outline Introduce Lab 1-2 Counting Timers on C8051 Interrupts Laboratory Worksheet #05 Copy

More information

Real Time Embedded Systems. Lecture 1 January 17, 2012

Real Time Embedded Systems.  Lecture 1 January 17, 2012 Low-Power & Reset Real Time Embedded Systems www.atomicrhubarb.com/embedded Lecture 1 January 17, 2012 Topic Section Topic Where in the books Catsoulis chapter/page Simon chapter/page Zilog UM197 (ZNEO

More information

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE AVR XMEGA Microcontrollers AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro APPLICATION NOTE Introduction This application note covers some of the power saving features of the Atmel XMEGA

More information

M16C/62 APPLICATION NOTE. Using the Expanded Memory Mode with the M16C/ Abstract. 2.0 Introduction. 3.0 Memory Expansion Mode

M16C/62 APPLICATION NOTE. Using the Expanded Memory Mode with the M16C/ Abstract. 2.0 Introduction. 3.0 Memory Expansion Mode APPLICATION NOTE M16C/62 1.0 Abstract The following article introduces and shows an example of how to access external memory using the expanded memory mode of the M16C/62 series of microcontrollers. 2.0

More information

Systems Programming. Lecture 4 Z16 Architecture and Programming

Systems Programming.   Lecture 4 Z16 Architecture and Programming Systems Programming www.atomicrhubarb.com/systems Lecture 4 Z16 Architecture and Programming Section Topic Where in the books Zilog Zilog Zilog Zilog UM197 (ZNEO Z16F Series Flash Microcontroller Contest

More information

CENG-336 Introduction to Embedded Systems Development. Timers

CENG-336 Introduction to Embedded Systems Development. Timers CENG-336 Introduction to Embedded Systems Development Timers Definitions A counter counts (possibly asynchronous) input pulses from an external signal A timer counts pulses of a fixed, known frequency

More information

timer 1 Fri Oct 13 13:00:

timer 1 Fri Oct 13 13:00: timer 1 Fri Oct 1 1:00: 1.1 Introduction SECTION CAPTURE/COMPARE TIMER This section describes the operation of the 1-bit capture/compare timer. Figure -1 shows the structure of the timer module. Figure

More information

Base Timer Channel (BT) Features. General Description. When to Use a PDL_BT Component 1.0

Base Timer Channel (BT) Features. General Description. When to Use a PDL_BT Component 1.0 1.0 Features Four operating modes 16-bit PWM Timer 16-bit PPG Timer 16/32-bit Reload Timer 16/32-bit PWC Timer Trigger generation for ADC conversion General The Peripheral Driver Library (PDL) Base Timer

More information

Zilog Real-Time Kernel

Zilog Real-Time Kernel An Company Configurable Compilation RZK allows you to specify system parameters at compile time. For example, the number of objects, such as threads and semaphores required, are specez80acclaim! Family

More information

The following article introduces and shows an example of how to set up and use the watchdog timer on the M16C/26 microcontroller (MCU).

The following article introduces and shows an example of how to set up and use the watchdog timer on the M16C/26 microcontroller (MCU). APPLICATION NOTE M16C/26 1.0 Abstract The following article introduces and shows an example of how to set up and use the watchdog timer on the M16C/26 microcontroller (MCU). 2.0 Introduction The Renesas

More information

AN2592 Application note

AN2592 Application note AN2592 Application note How to achieve 32-bit timer resolution using the link system in STM32F101xx and STM32F103xx microcontrollers Introduction In many applications, 32-bit resolution is required to

More information

CE58957 demonstrates how to implement the fade and toggle feature to the backlight LEDs of CapSense buttons.

CE58957 demonstrates how to implement the fade and toggle feature to the backlight LEDs of CapSense buttons. Objective CapSense Sigma Delta (CSD) with LED Backlight Fading on CY8C24x94 CE58957 Code Example Name: Example_CSD_BacklightFading_24x94 Programming Language: C Associated Part Families: CY8C24x94 Software

More information

EE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts

EE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts EE4800-03 Embedded Systems Design Lessons 7-10 - Exceptions - Resets and Interrupts 1 - Exceptions - Resets and Interrupts Polling vs. Interrupts Exceptions: Resets and Interrupts 68HC12 Exceptions Resets

More information

Introduction to Embedded Systems

Introduction to Embedded Systems Stefan Kowalewski, 4. November 25 Introduction to Embedded Systems Part 2: Microcontrollers. Basics 2. Structure/elements 3. Digital I/O 4. Interrupts 5. Timers/Counters Introduction to Embedded Systems

More information

Set Up a PLL Loop Filter on the ez80f91 MCU

Set Up a PLL Loop Filter on the ez80f91 MCU Application Note Set Up a PLL Loop Filter on the ez80f91 MCU AN017504-0108 Abstract This document provides information that will help an application developer effectively use the ez80f91 MCU s on-chip

More information

Boot Loader for the Z51F6412 MCU

Boot Loader for the Z51F6412 MCU Boot Loader for the Z51F6412 MCU AN037701-0215 Abstract This application note discusses how to create a boot loader program for the Z51F6412 microcontroller, a member of Zilog s Z8051 Family of Microcontrollers.

More information

AN-8205 AMC Library Hall Interface Summary AMC Introduction

AN-8205 AMC Library Hall Interface Summary AMC Introduction www.fairchildsemi.com AMC Library Hall Interface Summary The FCM8531 is an application-specific parallel-core processor for motor control that consists of an Advanced Motor Controller (AMC) processor and

More information

Capable of adjusting detection timings for start bit and data bit

Capable of adjusting detection timings for start bit and data bit PSoC Creator Component Datasheet Remote Control (PDL_RC) 1.0 Features Up to 2 Channels HDMI-CEC/ High Definition Multimedia Interface Consumer Electronics Control transmitter/receiver SIRCS/Sony Infrared

More information

PAC52XX GPIO Peripheral Firmware Design

PAC52XX GPIO Peripheral Firmware Design APPLICATION NOTE PAC52XX GPIO Peripheral Firmware Design TM Marc Sousa Senior Manager, Systems and Firmware www.active-semi.com Copyright 2014 Active-Semi, Inc. TABLE OF CONTENTS APPLICATION NOTE... 1

More information

General Purpose Programmable Peripheral Devices. Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

General Purpose Programmable Peripheral Devices. Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar Chapter 15 General Purpose Programmable Peripheral Devices by Rahul Patel, Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar Microprocessor & Interfacing (140701) Rahul Patel 1

More information

TMS320C6000 DSP 32-Bit Timer Reference Guide

TMS320C6000 DSP 32-Bit Timer Reference Guide TMS320C6000 DSP 32-Bit Timer Reference Guide Literature Number: SPRU582A July 2003 Revised October 2004 Contents TMS320C6000 DSP 32-Bit Timer... 2 Table of Contents... 2 Preface... 3 1 Overview... 5 2

More information

AN 547: Putting the MAX II CPLD in Hibernation Mode to Achieve Zero Standby Current

AN 547: Putting the MAX II CPLD in Hibernation Mode to Achieve Zero Standby Current AN 547: Putting the MAX II CPLD in Hibernation Mode to Achieve Zero Standby Current January 2009 AN-547-10 Introduction To save power, the MAX II CPLD can be completely powered down into hibernation mode

More information

Course Introduction. 2009, Renesas Technology America, Inc., All Rights Reserved

Course Introduction. 2009, Renesas Technology America, Inc., All Rights Reserved Course Introduction Purpose This course provides an introduction to the peripheral functions built into R8C Tiny series microcontrollers (MCUs). Objective Learn about the features and operation of the

More information

M16C/26 APPLICATION NOTE. Using the M16C/26 Timer in Event Counter Mode. 1.0 Abstract. 2.0 Introduction

M16C/26 APPLICATION NOTE. Using the M16C/26 Timer in Event Counter Mode. 1.0 Abstract. 2.0 Introduction APPLICATION NOTE M16C/26 1.0 Abstract Event counters are useful in automated packaging lines, tachometers, and mechanical equipment monitoring. The event counters on the M16C/26 can be configured to interrupt

More information

Using DMA for Pulse Counting on S32K

Using DMA for Pulse Counting on S32K Freescale Semiconductor, Inc. Document Number: AN5258 Application Note Rev. 0, 02/2016 Using DMA for Pulse Counting on S32K 1. Introduction This application note describes pulse counting on the S32K product

More information

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1. Counters and Timers: The 8051 microcontroller has two 16-bit timers/counters called T0 and T1. As their names suggest, timer counts internal clock pulse i.e. machine cycle to provide delay. Counter counts

More information

Chapter 2. Overview of Architecture and Microcontroller-Resources

Chapter 2. Overview of Architecture and Microcontroller-Resources Chapter 2 Overview of Architecture and Microcontroller-Resources Lesson 4 Timers, Real Time Clock Interrupts and Watchdog Timer 2 Microcontroller-resources Port P1 Port P0 Port P2 PWM Timers Internal Program

More information

SAM4 Reset Controller (RSTC)

SAM4 Reset Controller (RSTC) APPLICATION NOTE AT06864: SAM4 Reset Controller (RSTC) ASF PROGRAMMERS MANUAL SAM4 Reset Controller (RSTC) This driver for SAM devices provides an interface for the configuration and management of the

More information

I Introduction to Real-time Applications By Prawat Nagvajara

I Introduction to Real-time Applications By Prawat Nagvajara Electrical and Computer Engineering I Introduction to Real-time Applications By Prawat Nagvajara Synopsis This note is an introduction to a series of nine design exercises on design, implementation and

More information

Lecture-55 System Interface:

Lecture-55 System Interface: Lecture-55 System Interface: To interface 8253 with 8085A processor, CS signal is to be generated. Whenever CS =0, chip is selected and depending upon A 1 and A 0 one of the internal registers is selected

More information

Z8 Encore! XP -Based NiMH Battery Charger

Z8 Encore! XP -Based NiMH Battery Charger Application Note Z8 Encore! XP -Based NiMH Battery Charger AN022202-0707 Copyright 2007 by Zilog, Inc. All rights reserved. www.zilog.com Warning: DO NOT USE IN LIFE SUPPORT LIFE SUPPORT POLICY ZILOG'S

More information

Interrupts, timers and counters

Interrupts, timers and counters Interrupts, timers and counters Posted on May 10, 2008, by Ibrahim KAMAL, in Micro-controllers, tagged Most microcontrollers come with a set of ADD-ONs called peripherals, to enhance the functioning of

More information

PMC-DA Channel 16 Bit D/A for PMC Systems REFERENCE MANUAL Version 1.0 June 2001

PMC-DA Channel 16 Bit D/A for PMC Systems REFERENCE MANUAL Version 1.0 June 2001 PMC-DA816 8 Channel 16 Bit D/A for PMC Systems REFERENCE MANUAL 796-10-000-4000 Version 1.0 June 2001 ALPHI TECHNOLOGY CORPORATION 6202 S. Maple Avenue #120 Tempe, AZ 85283 USA Tel: (480) 838-2428 Fax:

More information

CE PSoC 4: Time-Stamped ADC Data Transfer Using DMA

CE PSoC 4: Time-Stamped ADC Data Transfer Using DMA CE97091- PSoC 4: Time-Stamped ADC Data Transfer Using DMA Objective This code example uses a DMA channel with two descriptors to implement a time-stamped ADC data transfer. It uses the Watch Dog Timer

More information

One 32-bit counter that can be free running or generate periodic interrupts

One 32-bit counter that can be free running or generate periodic interrupts PSoC Creator Component Datasheet Multi-Counter Watchdog (MCWDT_PDL) 1.0 Features Configures up to three counters in a multi-counter watchdog (MCWDT) block Two 16-bit counters that can be free running,

More information

IP-48DAC channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL Version 1.

IP-48DAC channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL Version 1. IP-48DAC-16 48-channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL 828-10-000-4000 Version 1.0 January 2007 ALPHI TECHNOLOGY CORPORATION 1898 E. Southern Ave Tempe,

More information

Microprocessors B (17.384) Spring Lecture Outline

Microprocessors B (17.384) Spring Lecture Outline Microprocessors B (17.384) Spring 2013 Lecture Outline Class # 04 February 12, 2013 Dohn Bowden 1 Today s Lecture Administrative Microcontroller Hardware and/or Interface Programming/Software Lab Homework

More information

F²MC-8FX Family MB95200H/210H Series Capacitance Touch Sensor

F²MC-8FX Family MB95200H/210H Series Capacitance Touch Sensor AN205062 Associated Part Family: MB95200H/210H Series This Application Note describes Cypress TSC solution, and explains how to use TSC library and TSC GUI. Contents 1 Introduction... 1 2 Cypress Capacitance

More information

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

Zatara Series ARM ASSP High-Performance 32-bit Solution for Secure Transactions 1 ARM-BASED ASSP FOR SECURE TRANSACTIONS ZATARA SERIES 32-BIT ARM ASSP PB022106-1008 ZATARA SERIES ADVANTAGE SINGLE-CHIP SOLUTION BEST FEATURE SET IN POS PCIPED PRE-CERTIFIED EMV L1 CERTIFIED TOTAL SOLUTION

More information

Use the Status Register when the firmware needs to query the state of internal digital signals.

Use the Status Register when the firmware needs to query the state of internal digital signals. 1.60 Features Up to 8-bit General Description The allows the firmware to read digital signals. When to Use a Use the when the firmware needs to query the state of internal digital signals. Input/Output

More information

Topics. Interfacing chips

Topics. Interfacing chips 8086 Interfacing ICs 2 Topics Interfacing chips Programmable Communication Interface PCI (8251) Programmable Interval Timer (8253) Programmable Peripheral Interfacing - PPI (8255) Programmable DMA controller

More information

Engineering Bulletin. Introduction and Background. Definition of Early TOF EB389/D 11/2001

Engineering Bulletin. Introduction and Background. Definition of Early TOF EB389/D 11/2001 Engineering Bulletin EB389/D 11/2001 TOF Considerations when Measuring a Long Input Capture Event By Donnie Garcia and Gianni Filippi Microcontroller Applications Engineering Austin, Texas Introduction

More information

EE 308 Spring A software delay

EE 308 Spring A software delay A software delay To enter a software delay, put in a nested loop, just like in assembly. Write a function delay(num) which will delay for num milliseconds void delay(unsigned int num) volatile unsigned

More information

CPEG300 Embedded System Design. Lecture 8 Timer

CPEG300 Embedded System Design. Lecture 8 Timer CPEG300 Embedded System Design Lecture 8 Timer Hamad Bin Khalifa University, Spring 2018 Review 8051 port and port schematic Internal read/write data path Serial communication vs. parallel communication

More information

This optional pin is present if the Mode parameter is set to SyncMode or PulseMode. Otherwise, the clock input does not show.

This optional pin is present if the Mode parameter is set to SyncMode or PulseMode. Otherwise, the clock input does not show. 1.60 Features Up to 8-bit General Description The allows the firmware to output digital signals. When to Use a Use a when the firmware needs to interact with a digital system. You can also use the as a

More information

AN2618 Application note

AN2618 Application note Application note etpu host interface Introduction The etpu is the new generation of Time Processing Unit (TPU). Besides the hardware enhancement, significant improvements have been made to the accompanying

More information

This document describes how to set up and use the timer RB in programmable one-shot generation mode on the R8C/25 Group device.

This document describes how to set up and use the timer RB in programmable one-shot generation mode on the R8C/25 Group device. APPLICATION NOTE R8C/25 Group 1. Abstract This document describes how to set up and use the timer RB in programmable one-shot generation mode on the R8C/25 Group device. 2. Introduction The application

More information

Timers and Pulse Accumulator

Timers and Pulse Accumulator 7 7.1 Objectives: Tiva is equipped with six General Purpose Timer Modules named TIMERn. Additionally, each TIMERn consists of two 16 bit timers (A and B). Most GPIO pins can be assigned a TIMERn as an

More information

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information

Nios Soft Core Embedded Processor

Nios Soft Core Embedded Processor Nios Soft Core Embedded Processor June 2000, ver. 1 Data Sheet Features... Preliminary Information Part of Altera s Excalibur TM embedded processor solutions, the Nios TM soft core embedded processor is

More information

EE4390 Microprocessors

EE4390 Microprocessors EE4390 Microprocessors Lessons 23, 24 - Exceptions - Resets and Interrupts Revised: Aug 1, 2003 1 - Exceptions - Resets and Interrupts Polling vs. Interrupts Exceptions: Resets and Interrupts 68HC12 Exceptions

More information

Signature: 1. (10 points) Basic Microcontroller Concepts

Signature: 1. (10 points) Basic Microcontroller Concepts EE 109 Practice Final Exam Last name: First name: Signature: The practice final is one hour, ten minutes long, closed book, closed notes, calculators allowed. To receive full credit on a question show

More information

Emulating Dual SPI Using FlexIO

Emulating Dual SPI Using FlexIO Freescale Semiconductor, Inc. Document Number: AN5242 Application Note Rev. 0, 01/2016 Emulating Dual SPI Using FlexIO 1. Introduction This application note discusses one example of how to use FlexIO module

More information

C Language Programming, Interrupts and Timer Hardware

C Language Programming, Interrupts and Timer Hardware C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and

More information

Emulating I2C Bus Master by using FlexIO

Emulating I2C Bus Master by using FlexIO Freescale Semiconductor, Inc. Document Number: AN5133 Application Notes Rev. 0, 06/2015 Emulating I2C Bus Master by using FlexIO 1. Introduction This application note lists the steps to use the FlexIO

More information

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B

CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B CPE 325: Embedded Systems Laboratory Laboratory #7 Tutorial MSP430 Timers, Watchdog Timer, Timers A and B Aleksandar Milenković Email: milenka@uah.edu Web: http://www.ece.uah.edu/~milenka Objective This

More information