CHAPTER 8 8/16-BIT CAPTURE TIMER/COUNTER

8.11Program Example for 8/16-bit Capture Timer/Counter

This section provides program examples of the 8/16-bit capture timer/counter.

Program Example of Interval Timer Function

Processing specifications

In the 8-bit mode, only timer 0 is used to generate a 20 ms interval timer interrupt.

When the interval time has elapsed, the square wave to be inverted is output to the TO pin.

At 12.5-MHz oscillation (FCH), the TDR0 value whose interval time becomes 20 ms at the maximum gear speed (1 instruction cycle = 4/FCH) is shown below. The count clock is 256tINST of the internal count clock.

TDR0 value = 20 ms/(256 4/12.5 MHz) - 1 = 244 (F4H)

Coding example

TCCR

EQU

0019H

;

Address of capture control register

TCR1

EQU

001AH

;

Address of timer 1 control register

TCR0

EQU

001BH

;

Address of timer 0 control register

TCR2

EQU

0020H

;

Address of timer output control register

TDR1

EQU

001CH

;

Address of timer 1 data register

TDR0

EQU

001DH

;

Address of timer 0 data register

TIF0

EQU

TCR0:7

;

Defines the timer 0 interrupt request flag bit.

ILR1

EQU

007BH

;

Address of interrupt request setting register

INT_V

DSEG

ABS

;

[DATA SEGMENT]

 

ORG

0FFF0H

 

 

IRQD

DW

WARI

;

Sets an interrupt vector.

 

ENDS

 

 

 

;------------------------

Main program---------------------------------------------------------------------------------

 

 

CSEG

 

;

[CODE SEGMENT]

 

 

 

; The stack pointer (SP), etc., is already initialized.

 

:

 

 

 

 

CLRI

 

;

Disables the interrupt.

 

MOV

ILR1,#10111111B

;

Sets the interrupt level to 2.

 

MOV

TCR0,#01001010B

;

Clears the timer 0 interrupt request flag, increments the

 

 

 

 

counter at a rising edge, selects 256tINST, and stops the

 

 

 

 

operation.

 

MOV

TCR1,#01000010B

;

Clears the timer 1 interrupt request flag, prohibits

 

 

 

 

interrupt request output, sets a mode other than the 16-

 

 

 

 

bit mode, and stops the operation.

 

MOV

TDR0,#F4H

;

Sets the value (interval time) to be compared with the

 

 

 

 

counter value.

200

Page 216
Image 216
Fujitsu MB89202, F202RA manual Program Example for 8/16-bit Capture Timer/Counter

F202RA, MB89202 specifications

The Fujitsu MB89202 and F202RA microcontrollers are part of the 16-bit microcontroller family, renowned for their robust performance and versatility in a variety of embedded system applications. These devices are tailored for high-efficiency operation across diverse industries, including automotive, consumer electronics, and industrial automation.

One of the main features of the MB89202 is its powerful CPU core, which operates at a clock speed of up to 20 MHz. This enables the microcontroller to perform complex calculations and consumer-grade applications seamlessly. The architecture is designed to handle multiple tasks effectively, making it suitable for real-time operations.

Memory capacity is a vital characteristic of the MB89202, featuring on-chip RAM and ROM configurations. The microcontroller can accommodate different memory variants, providing developers with flexibility in memory allocation based on their application requirements. This adaptability facilitates applications ranging from simple control systems to complex data processing tasks.

The F202RA variant extends the capabilities of the MB89202 by integrating advanced peripheral functions. It includes built-in timers, A/D converters, and serial communication interfaces, which are essential for interfacing with other hardware components or sensors. The availability of these peripherals reduces the need for additional external circuits, thus contributing to a more compact and cost-effective design.

In terms of power management, the MB89202 series employs advanced power-saving technologies. The microcontroller offers various low-power modes, enabling devices to conserve energy during idle times, making it highly suitable for battery-operated applications. This characteristic not only enhances the efficiency of devices but also extends their operational lifespan.

Moreover, the Fujitsu MB89202 series incorporates robust protection features, including watchdog timers and failure detection mechanisms. These safety features ensure reliable operation in critical systems, making them a preferred choice in applications where failure is not an option.

The MB89202 and F202RA microcontrollers also support a range of development tools and environments, including integrated development environments (IDEs) and software libraries, which facilitate rapid application development. With these tools, developers can efficiently prototype, debug, and optimize their applications.

In summary, the Fujitsu MB89202 and F202RA microcontrollers stand out with their efficient performance, extensive memory options, integrated peripherals, and power-saving capabilities, making them ideal for a wide array of embedded applications. Their reliability and robustness further enhance their attractiveness for designers seeking advanced microcontroller solutions.