2-4 A 8-bit 16-bit timer, a peripheral initial
data1 &= ~TM1MD_START1;
TM1MD = data1; /* Timer 1 start LDE=0 */
data1 |= TM1MD_ENABLE1;
TM1MD = data1; /* Timer 1 permission CNE=1 */
data0 |= TM0MD_ENABLE1;
TM0MD = data0; /* Timer 0 permission CNE=1 */
TM03PSC = PS0MD_START; /* Pre-scaler start */
TM0MD = TM0MD_START2; /* Timer start*/
TM1MD = TM1MD_START2; /* Timer start */
}
The sample of a 8-bit timer is recorded on attached CD-ROM.
Inclusion director:program\initial\timecounter\timer8\
program :timer8int.c
It is a setup when using it as an event timer.
/*******************************
* Register address
*******************************/
/* Timer 0 register address declaration */
#define TM0BC (*((volatile unsigned char *)0x0000A150))
#define TM0BR (*((volatile unsigned char *)0x0000A148))
#define TM0MD (*((volatile unsigned char *)0x0000A140))
/* Timer 1 register address declaration */
#define TM1BC (*((volatile unsigned char *)0x0000A151))
#define TM1BR (*((volatile unsigned char *)0x0000A149))
#define TM1MD (*((volatile unsigned char *)0x0000A141))
/* Timer 2 register address declaration */
#define TM2BC (*((volatile unsigned char *)0x0000A154))
#define TM2BR (*((volatile unsigned char *)0x0000A14C))
#define TM2MD (*((volatile unsigned char *)0x0000A144))
/* Timer 3 register address declaration */
#define TM3BC (*((volatile unsigned char *)0x0000A155))
#define TM3BR (*((volatile unsigned char *)0x0000A14D))
#define TM3MD (*((volatile unsigned char *)0x0000A145))
/* Timer 4 register address declaration */
#define TM4BC (*((volatile unsigned char *)0x0000A170))
#define TM4BR (*((volatile unsigned char *)0x0000A168))
#define TM4MD (*((volatile unsigned char *)0x0000A160))
/* Timer 5 register address declaration */
#define TM5BC (*((volatile unsigned char *)0x0000A171))
#define TM5BR (*((volatile unsigned char *)0x0000A169))
#define TM5MD (*((volatile unsigned char *)0x0000A161))
/* Timer 6 register address declaration */
#define TM6BC (*((volatile unsigned char *)0x0000A174))
#define TM6BR (*((volatile unsigned char *)0x0000A16C))
#define TM6MD (*((volatile unsigned char *)0x0000A164))
2-37