TOSHIBA SP-900-011 Technical data

TLCS-900/H Sample Progr am Description
This sample program is created targetting at the TLCS-900/H series. When using an MCU other than the TLCS-900/H series, refer to the data sheet for that MCU.
2. Overview
This sample program measures a pulse width using a 16-bit timer.
3. Description
The program meas ures a pulse width using a 16-b it timer in e vent counter m ode with an 8- bit timer. It can measure the high-level width of an external pulse. The following describes timer 8 and timer 0/1 as an example.
To use the program , the UC8 16-bit up cou nter must be operat ing in free runnin g mode using the internal clock. T he program triggers captur ing at the r ising and fall ing edges of the external pulses on the TI8 pin and fetches the up counter value into the CAP1 and CAP2 capture registers, respectively. The INT5 interrupt handler calculates the difference between the CAP1 and CAP2 and multiplies the difference by the internal clock period to obtain the high-level width.
--Measuring Pulse Width Using 16-bit Timer--
SP-900-011
PLWDMSR
Rev 1.1
Dec. 2005
Copyright© TOSHIBA CORPORATION 2005 All rights Reserved.
1/3
TLCS-900/H Sample Program Description
Figure 1 Measurement the high-level width
Example: When the difference between the CAP1 and CAP2 is 100 and the internal clock period is 0.8 µs, the high-level width is 100 * 0.8 µs = 80 µs.
4. Passing Data
Use the following variables to exchange data:
gCAP1: Buffer for CAP1
gCAP2: Buffer for CAP2
gINT5CT: Edge counter
gFLAG0: Cycle end flag
gPLSWD: Difference between CAP1 and CAP2
5. Interrupts
INTT0: 16-µs cycle (example)
INTTO8
Copyright© TOSHIBA CORPORATION 2005 All rights Reserved.
2/3
Loading...
+ 1 hidden pages