2-4 A 8-bit 16-bit timer, a peripheral initial
/* Timer 7 register address declaration */
#define TM7BC (*((volatile unsigned char *)0x0000A175))
#define TM7BR (*((volatile unsigned char *)0x0000A16D))
#define TM7MD (*((volatile unsigned char *)0x0000A165))
/* Pre-scaler register address declaration */
/* timer 0-3 */
#define TM03PSC (*((volatile unsigned char *)0x0000A158))
/* timer 4-7 */
#define TM47PSC (*((volatile unsigned char *)0x0000A178))
/* Pre-scaler control register */
#define TMEXPSC8 (*((volatile unsigned char *)0x0000A17C))
/* Declaration of setting data */
#define TM0MD_STOP 0x00 /* Timer stop*/
#define TM0_COUNT4 3 /* cycles/min ratio setup (4 cycles/min-1) */
#define TM0MD_LOAD1 0x07 /* TMIN0 Terminal input setup */
#define TM0MD_STABLE1 0x00 /* Stabilization */
#define TM0MD_START1 0x40 /* timer start*/
#define TM0MD_ENABLE1 0x80 /* Timer permission */
#define PS0MD_STOP 0x00 /* Pre-scaler stop*/
#define PS0MD_START 0x80 /* Pre-scaler start*/
#define TM1MD_STOP 0x00 /* timer stop*/
#define TM1_COUNT3 5 /* cycles/min ratio setup(5 cycles/min-1) */
#define TM1MD_LOAD1 0x03 /* cycles/min ratio reloaded */
#define TM1MD_STABLE1 0x00 /* stabilization*/
#define TM1MD_START1 0x40 /* timer start*/
#define TM1MD_ENABLE1 0x80 /* timer permission */
#define PS0_COUNT200 199 /* cycles/min ratio setup (200 cycles/min-1) */
#define TM0_COUNT0x5f 0x5f /* cycles/min ratio setup (0xea5f = 0xea60(60000) - 1) */
#define TM1_COUNT0xea 0xea /* cycles/min ratio setup (0 xea5f = 0xea60(60000) - 1) */
#define TM0MD_LOAD2 0x42 /* cycles/min ratio reloaded */
/* Clock source (Pre-scaler 0 clock) setup*/
#define TM1MD_LOAD2 0x03 /* timer 0 and cascade connection */
#define TM0MD_STABLE2 0x02 /* stabilization */
#define TM1MD_STABLE2 0x01 /* stabilization */
#define TM0MD_START2 0x82 /* timer start */
#define TM1MD_START2 0x81 /* timer start */
/***********************************************
* Event counter by 8-bit timer
* TMIN0 terminal is carried out for 1 / 4 cycles/min using a timer 0,
* and underflow interruption is generated.
***********************************************/
void initEventCounter8( void )
{
unsigned short data;
data = TM0MD_STOP;
TM0MD = data; /* timer stop */
/* TM0 underflow interruption is permitted. */
2-38