Generating DTMF Tones Using Z8 Encore! MCU

Similar documents
Using Z8 Encore! XP MCU for RMS Calculation

DTMF Signal Detection Using Z8 Encore! XP F64xx Series MCUs

Using the Z8 Encore! XP Timer

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

Electric Bike BLDC Hub Motor Control Using the Z8FMC1600 MCU

Crystal Oscillator/Resonator Guidelines for ez80 and ez80acclaim! Devices

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

AN3252 Application note

A Unipolar Stepper Motor Drive Using the Z8 Encore! MCU

AN3332 Application note

Project Final Report: Directional Remote Control

Designing with a Microcontroller (v6)

Sampling and Quantization

Lab 5 Timer Module PWM ReadMeFirst

AN2979 Application note

AT15291: Migrating QTouch Designs from SAM D MCUs to SAM C MCUs. Scope. Features. QTouch APPLICATION NOTE

Servo Sequencer Servo Robot motion controller & General Purpose microcontroller board

AN2668 Application note

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

High Group Hz Hz. 697 Hz A. 770 Hz B. 852 Hz C. 941 Hz * 0 # D. Table 1. DTMF Frequencies

AN2581 Application note

AN4507 Application note

ZLS38503 Firmware for Voice Prompting and Messaging Firmware Manual

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

LMH7324 High Speed Comparator Evaluation Board

Microprocessor & Interfacing Lecture Programmable Interval Timer

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

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

DTMF Detection and Generation Virtual Peripheral Modules

EE-4022 Experiment 2 Amplitude Modulation (AM)

AN1449 Application note

Normal Oscillator Behavior (Device A) Figure 1. Normal Oscillator Behavior (Device A) ft = f0 1 + TC1 T T0

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

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

Slim Series SIR Top Look Transceiver

AP CANmotion. Evaluation Platform with BLDC Motor featuring XC886CM Flash Microcontroller Version 2007/10. Microcontrollers

ZKit-51-RD2, 8051 Development Kit

LP3943/LP3944 as a GPIO Expander

RC Filters and Basic Timer Functionality

CSCI1600 Lab 4: Sound

General-Purpose OTP MCU with 14 I/O LInes

RX23T inverter ref. kit

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

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

CHAPTER-5 DESIGN OF DIRECT TORQUE CONTROLLED INDUCTION MOTOR DRIVE

Edition Published by Infineon Technologies AG Munich, Germany 2010 Infineon Technologies AG All Rights Reserved.

DEMO MANUAL DC961B LT1994 Low Noise, Low Distortion, Fully Differential Amplifier/Driver. Description

AN2679 Application note

8-bit RISC Microcontroller. Application Note. AVR314: DTMF Generator

Using PWM Output as a Digital-to-Analog Converter on a TMS320C240 DSP APPLICATION REPORT: SPRA490

Microcontroller: Timers, ADC

EE445L Spring 2018 Final EID: Page 1 of 7

FlexTimer and ADC Synchronization

BINARY AMPLITUDE SHIFT KEYING

AN4062 Application note

LM48821 Evaluation Board User's Guide

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

AN2446 Application note

32-bit Microcontroller for Home

Dr. Cahit Karakuş ANALOG SİNYALLER

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

THE PERFORMANCE TEST OF THE AD CONVERTERS EMBEDDED ON SOME MICROCONTROLLERS

XC83x AP Application Note. Microcontrollers. intouch Application Kit - Touch Sliders V1.0,

CPC9909EB. Hi-Brightness, Off-Line LED Driver Evaluation Board User s Guide INTEGRATED CIRCUITS DIVISION

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab

ADC Bit µp Compatible A/D Converter

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

ADVANCED EMBEDDED MONITORING SYSTEM FOR ELECTROMAGNETIC RADIATION

Technical Proposal for COMMON-ISDN-API. Version 2.0. Generic Tone Generator and Detector Support for Voice Applications. Extension.

CDM10V programming user manual describes the COOLDIM_PRG_BOARD burner board usage, the UART protocol handling and the fusing details.

Lab 13: Microcontrollers II

75T2089/2090/2091 DTMF Transceivers

78A207 MFR1 Receiver DATA SHEET DESCRIPTION FEATURES OCTOBER 2005

TS3003 Demo Board FEATURES COMPONENT LIST ORDERING INFORMATION. TS3003 Demo Board TS3003DB

Motor Control using NXP s LPC2900

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Lifetime Power Energy Harvesting Development Kit for Wireless Sensors User s Manual - featuring PIC MCU with extreme Low Power (XLP) Technology

Firmware plugin for STSW-ESC001V1 board with ST Motor Control FOC SDK

Dual FOC Servo Motor Control on i.mx RT

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

PHYTER 100 Base-TX Reference Clock Jitter Tolerance

AN4112 Application note

Application description AN1014 AM 462: processor interface circuit for the conversion of PWM signals into 4 20mA (current loop interface)

MB1503. LOW-POWER PLL FREQUENCY SYNTHESIZER WITH POWER SAVE FUNCTION (1.1GHz) Sept Edition 1.0a DATA SHEET. Features

MICROCONTROLLER TUTORIAL II TIMERS

CD22202, CD V Low Power DTMF Receiver

Figure 1. C805193x/92x Capacitive Touch Sense Development Platform

Part VI: Requirements for Integrated Services Digital Network Terminal Equipment

University of Florida EEL 3744 Fall 2017 Dr. Eric M. Schwartz Electrical and Computer Engineering Dept. Revision 3 1-Nov-17 Page 1/7

AN4379 Application note

UM1763 User manual. Description of STLUX385A examples kit. Introduction. Reference documents

Driving 2W LEDs with ILD4120

AN3116 Application note

LABORATORY 4. Palomar College ENGR210 Spring 2017 ASSIGNED: 3/21/17

Improving feedback current accuracy when using H-Bridges for closed loop motor control

LB1945D. PWM Current Control Stepping Motor Driver

VORAGO Timer (TIM) subsystem application note

Successive approximation (capacitive coupling amplifier)

DTMF receiver for telephones

MAX11300PMB1 Peripheral Module and Munich (USB2PMB1) Adapter Board Quick Start Guide

Transcription:

Application Note Generating DTMF Tones Using Z8 Encore! MCU AN024802-0608 Abstract This Application Note describes how Zilog s Z8 Encore! MCU is used as a Dual-Tone Multi- (DTMF) signal encoder to generate DTMF tones. Z8 Encore! microcontrollers have built-in timers and direct memory access (DMA) with three independent channels (DMA0, DMA1, and DMA2). The timers have Pulse-Width Modulation (PWM) capability and the PWM register values are loaded using DMA. These features of Z8 Encore! are used to generate DTMF signals with less processor overhead. Note: The source code associated with this Application Note is available under Z8 Encore! Applications Library in Application Sample Libraries on www.zilog.com. Z8 Encore! Microcontrollers Z8 Encore! products are based on the ez8 CPU and introduce Flash memory to Zilog s extensive line of 8-bit microcontrollers. The Flash memory in-circuit programming capability allows 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 ez8 CPU, the new Z8 Encore! microcontrollers combine a 20 MHz core with Flash memory, linear-register static random access memory (SRAM), and an extensive array of onchip peripherals. These peripherals make the Z8 Encore! MCU suitable for a variety of applications including motor control, security systems, home appliances, personal electronic devices, and sensors. Discussion This section discusses Dual-Tone Multi- (DTMF) basics and its implementation using microcontroller. DTMF is an international signaling standard for touch-tone telephones. The DTMF encoder encodes standard telephone digits into sum of sinusoid frequency pair corresponding to a frequency table. The DTMF decoder takes a digital signal as input and converts to the decoded digit. The DTMF standard developed by Bell Laboratories is used in touch-tone telephones and voice mail systems. Each telephone digit corresponds to High and Low tone that are transmitted simultaneously. Four frequencies in the High and Low group provide 16 possible combinations; 12 digits are used in most of the telephones and 4 digits are used in military applications. A DTMF detector must conform to the International Telecommunication Union (ITU) formerly known as International Telegraph and Telephone Consultative Committee (CCITT) recommendations. Table 1 lists the frequencies corresponding to each digit. Table 1. DTMF Table Low-Group Frequencies High-Group Frequencies 1209 1336 1477 1633 697 1 2 3 A 770 4 5 6 B 852 7 8 9 C 941 * (E) 0 # (F) D Copyright 2008 by Zilog, Inc. All rights reserved. www.zilog.com

Theory of Operation The DTMF tone is a combination of two sinusoids of different frequencies. Pulse-width modulation (PWM) method is the easiest and best way to generate a sine wave from a microcontroller. Sine Wave Generation Using PWM In PWM method, the duty cycle determines the amplitude of the sine wave and the number of samples determines the frequency of the sine wave. A sine wave is generated when the PWM output is passed through a low pass filter (LPF). To generate a DTMF tone, two timers in PWM mode are used for each frequency and their outputs are together passed through the LPF. Figure 1 displays the relation between signal frequency (1/T), sampling period (Ts), and number of samples (N). Ts Figure 1. Sine Wave Generation Using PWM From Figure 1, ( Number of samples (N)) ( Sampling Period (Ts)) = Signal Period (T) Therefore, N Fs = 1 F...(1) Fs = NF where, Fs is the sampling frequency and F is the signal frequency. PWM duty cycle registers are loaded using either of the following methods: Timer Interrupt Direct Memory Access Timer Interrupt In the Timer Interrupt method, the PWM registers are loaded at every timer interrupt (or as determined by the number of samples). The timer interrupts occur at the rate of the sampling frequency and servicing of these interrupts keeps the processor busy. Direct Memory Access In the Direct Memory Access (DMA) method, DMA is used to load PWM duty cycle register. The usage of DMA reduces the processor overhead. The user interface with this application provides a feature to calculate the processor overhead. For more information, see Testing on page 6. User application seamlessly integrates with the DTMF generation application as the DMA allows enough processing time for other application. AN024802-0608 Page 2 of 11

Lookup Table Formation The lookup table is used to load the PWM timer reload and duty cycle registers. The PWM duty cycle registers are loaded at the rate of the sampling frequency. For DTMF generation, sinusoids of different frequencies are required. A single lookup table is used for this purpose and the values are scaled to achieve the desired output frequency. Calculating Timer Reload Value The following example describes the method of obtaining PWM timer reload value for different frequencies. Let the base frequency be 697 Hz, the system clock be 18.432 MHz, and samples per cycle be 104 s. The time period is calculated as, Tbase = 1 697 = 1.43472 ms From Equation (1), N Ts = T Ts = T N == 1.43472 104 13.7953 μs where, Ts is the time period of PWM. Therefore, the timer reload register value is calculated as, Reload = ( Ts System Clock Prescalar) == 13.7953 18.432 1 254.27 = 254 Reload = 0 FE (hexadecimal representation) This corresponds to a sampling frequency of 72.488 khz (1/Ts). The time periods for all other frequencies are expressed as multiple of the time period of the base frequency. The multiplier values are scaled by 256 to avoid floating point operations. Using these multiplier values the timer reload value for other frequencies is calculated. Consider the example of 770 Hz signal. Time period = 1 770 = 1.2987 ms In terms of the base signal, Multiplier value = 1.2987 Tbase = 1.2987 1.43472 = 0.90519 The multiplier value is scaled by 256. Therefore, Multiplier value = 0.90519 256 = 231.728 = 232 The timer reload value for this signal (expressed as a multiple of the base frequency) is given by, Timer reload value = ( 232 254) 256 = 230 Therefore, the frequency is given by, F = System clock ( Number of samples Reload) = 18432000 ( 104 23) = 770.568 Hz Percentage Error = ( 770.568 770) 770 100 = 0.073% Calculating PWM Values The PWM values are calculated as follows: The sine value corresponding to the samples is given by, sin( n) = sin( 2 π n N) AN024802-0608 Page 3 of 11

For example, for sin(10), sin( 2 π n N) = sin( 2 π 10 104) = 0.56806 Note: One is added to all the sine values to make the sine value positive as negative PWM values are not acceptable. Therefore, sin( 2 π n N) = 0.56806 + 1= 1.56806 Let the minimum PWM value be 15, then the corresponding PWM value is, PWM value = 1.56806( Timer reload value Minimum PWM value) 2 + Minimum PWM value = 1.56806( 254 15) 2 + 15 = 202 The PWM values are also scaled according to the multiplier before loading to the PWM registers. For example, for 770 Hz frequency, the multiplier value calculated above is 232. Therefore, the PWM value corresponding to sample 10 for 770 Hz is given by, PWM value = 202 232 256 = 183 Note: For detailed calculations, refer to the spread sheet provided in the Application Sample Library on www.zilog.com. The spread sheet automatically calculates all the necessary values for a given number of samples, system clock, and timer prescale. AN024802-0608 Page 4 of 11

Developing the DTMF Encoder Using Z8 Encore! MCU Low Pass Filter Design The PWM outputs are passed through a LPF to demodulate and get the DTMF signal. A simple resistor-capacitor (RC) filter is used for this purpose. The RC values are calculated as follows: The maximum frequency in the DTMF signaling is 1633 Hz. For example, if the cut-off frequency (Fo) of an resistor-capacitor (RC) filter is 3000 Hz, then, Fo = 1 2 π RC Let C = 0.2 µf Therefore, R = 1 2 π 3000 200 10 9 = 265.25 = 270 Ω 270 T1out (PC1) /\/\/\/\ T2out (PC7) /\/\/\/\ 270 Oscilloscope/Line in on PC 0.2 F GND Figure 2. Low Pass Filter Software Implementation This section describes the software to generate DTMF signals using timer and DMA of Z8 Encore! MCU. The input to the application is a digit whose DTMF signal is required. The index to the specific frequencies is obtained from the DTMF frequency table defined in sine_table.asm file. Each index refers to the multiplication factors for that frequency. The first value in the _SineTable is the timer compare value of the base frequency. The remaining values represent the first half of the sine wave. The second half is generated by the software as a mirror image of the first half. During operation, these values are transferred to the Timer PWM low register via DMA. The timer reload value is calculated by multiplying the base timer compare value with the multiplication factor. Only the most significant byte (MSB) is considered. For more information on the software flow, see the flow charts in Appendix B Flowcharts on page 9. Loading PWM Register Using DMA The DMA of Z8 Encore! is used to load the PWM registers. The Z8 Encore! XP F64XX Series DMA controller consists of three independent DMA channels (DMA0, DMA1, and DMA_ADC). DMA0 and DMA1 transfer data between the onchip peripherals and the register file. The third channel (DMA_ADC) controls the Analog-to- Digital Converter (ADC) operation and transfers SINGLE-SHOT mode ADC output data to the register file. In this application, Timer2 is associated with DMA0 to generate Low tone and Timer1 is tied to DMA1 to generate High tone. The source (start address) for the DMAs is the start address of the corresponding sine table. The sine tables thus formed are scaled and mirrored. The destination (peripheral) address of DMA0 and DMA1 are the PWM Low byte registers of Timer2 and Timer1 respectively. AN024802-0608 Page 5 of 11

Testing The source code present in the associated Application Sample Library consists of a console interface for demonstration of this application. Setup Figure 3 displays the setup for generation of DTMF tones using the Z8 Encore! MCU. JP2 J1 T1out T2out CONSOLE PC-HyperTerminal LPF Oscilloscope DBG Figure 3. Setup for Generation of DTMF Tones Using Z8 Encore! XP F64XX Series Development Board Equipments Used The equipments used for the setup are listed below: Z8 Encore! development kit featuring Z8F64200100KIT development board ZDSII IDE Oscilloscope A PC equipped with HyperTerminal configured to the following settings: 57600 baud rate 8 data bits No parity One stop bit No flow control Procedure to Test the DTMF Application Follow the steps below to test the DTMF application: 1. Connect the external LPF to the timer outputs (see Figure 3). 2. Connect the console port output to the COM port configured with the HyperTerminal. 3. Install Z8 Encore! Applications Library available under Application Sample Libraries on www.zilog.com. 4. Launch ZDS II and open the DTMF.zdsproj project file located in the source folder. 5. Build and download the code to the Z8 Encore! development board. 6. Execute the code. The user interface routine prints a list of menu items in the HyperTerminal window. AN024802-0608 Page 6 of 11

7. Select the appropriate menu item and follow the instructions to generate the DTMF signals. Relevant APIs are called automatically and the DTMF signal is viewed on the oscilloscope. The DTMF signal can also be fed to the Line in on a PC and listened through the speaker output for demonstration purposes. Result The DTMF signals as well as the individual sine wave outputs are captured on the oscilloscope. Table 2 lists the percentage error in the output frequencies. Table 2. Percentage Error in the Output Frequencies Observed Low-Tone Expected Low-Tone Low-Tone Difference % Error in Low-Tone Observed High-Tone Expected High-Tone High-Tone Difference 942 941 1 0.11 1339 1336 3 0.22 702 697 5 0.72 1208 1209-1 -0.08 769 770-1 -0.13 1488 1477 11 0.74 851 852-1 -0.12 1642 1633 9 0.55 % Error in High-Tone Summary This Application Note provides a quick solution to generate DTMF tones using the DMA and timer feature set of the Z8 Encore! MCUs. The PWM mode of the timers combined with the DMA gives the flexibility to integrate the application that use tone generation as a subset. This method greatly reduces processor overhead compared to other microcontrollers where interrupts are used. References The documents associated with ez8 and Z8 Encore! XP available on www.zilog.com are provided below: ez8 TM CPU User Manual (UM0128) Z8 Encore! XP F64XX Series Product Specification (PS0199) AN024802-0608 Page 7 of 11

Appendix A Glossary Table 3 lists the abbreviations and definitions used in this Application Note. Table 3. List of Abbreviations Abbreviation Definition API Application Programming Interface DBG Debug Pin-on Development Board DMA Direct Memory Access DTMF Dual-Tone Multi- LPF Low Pass Filter MCU Microcontroller Unit PWM Pulse-Width Modulation SRAM Static Random Access Memory AN024802-0608 Page 8 of 11

Appendix B Flowcharts Appendix B provides the flowchart for loading the sine table and PWM registers using DMA. The steps followed in the flowchart for loading the sine table (see Figure 4) are same for loading Low and High tone table. START Get the digit(s) whose DTMF is to be generated Calculate the index offset for DTMF frequency table Get the address of the multiplication factor Scale and transfer the timer compare value which determines the frequency of the output waveform Scale and transfer the half sine wave stored in the program space (ROM) to the RAM table. If the tone multiplication factor is 0, then the sine table values are not scaled. Mirror the calculated values for the second half of the sine wave END Figure 4. Flowchart for Loading the Sine Table AN024802-0608 Page 9 of 11

START Turn OFF Timer1, Timer2, DMA0, and DMA1 Load DMA start and end address (sine table address) Load DMA destination address (PWM registers) Load timer reload value Start DMA0 and DMA1 DTMF ON time elapsed No Yes Turn OFF Timer1, Timer2, DMA0, and DMA1 END Figure 5. Flowchart for Loading the PWM Registers Using DMA AN024802-0608 Page 10 of 11

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 2008 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 Encore!, Z8 Encore! XP, and ez8 are trademarks or registered trademarks of Zilog, Inc. All other product or service names are the property of their respective owners. AN024802-0608 Page 11 of 11