
Pulse Period/Width Measurement on the M16C/62 
M16C
6. Software Code 
The software supplied by Mitsubishi Electric & Electronics USA, Inc. is intended and supplied for use on Mitsubishi 
Electric products. This software is owned by Mitsubishi Electric & Electronics USA, Inc. or Mitsubishi Electric 
Corporation and is protected under applicable copyright laws. All rights are reserved.  
THIS SOFTWARE IS PROVIDED “AS IS”. NO WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, 
INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. MITSUBISHI ELECTRIC & ELECTRONICS USA, INC. 
AND MITSUBISHI ELECTRIC CORPORATION RESERVE THE RIGHT, WITHOUT NOTICE, TO MAKE CHANGES 
TO THIS SOFTWARE. NEITHER MITSUBISHI ELECTRIC & ELECTRONICS USA, INC. NOR MITSUBISHI 
ELECTRIC CORPORATION SHALL, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR 
CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER ARISING OUT OF THE USE OR 
APPLICATION OF THIS SOFTWARE. 
Below is a program written for Mitsubishi’s NC30 compiler to illustrate how to configure Pulse  
Period/Pulse Width Measurement Mode. The program can measure up to about a 16msec period and 
runs on the MSV1632 Starter Kit Board. Using the KD30 debugger, the program can be ‘stopped’ and the 
global variables ‘widthlow’, ‘width_hi’, and ‘period’ viewed from the global watch window. 
To become familiar with this mode, try changing the clock source or even switch to a different timer (e.g. 
TB2, TB3, etc.). 
/***************************************************************************** 
* 
* 
File Name: period_width.c  
*  
* 
Content: Example program using Timer B in 'pulse width / period measurement 
* 
 mode'. This program is written for the "Pulse Period/Width 
* 
 Measurement" application note. Timer B0 is configured to measure  
* 
 pulse width(TB0in pin),and timer B1,measures the period(TB1in pin). 
* 
 Tested using a 250Hz square wave with a 0.5msec pulse width(high). 
* 
 This program works with the MSV1632 starter kit board. 
* 
* 
Compiled with NC30 ver. 3.20.00. 
* 
* 
All timing based on 16 Mhz Xtal 
*  
* 
Copyright,2001 MITSUBISHI ELECTRIC CORPORATION  
* 
AND MITSUBISHI SEMICONDUCTOR SYSTEM CORPORATION 
* 
and Mitsubishi Electric and Electronics USA  
*============================================================================= 
* 
$Log:$ 
*===========================================================================*/ 
AN-DECE-MCU-6-A 
May 2002 
7