Download Print this page

Panasonic PanaXSeries MN103S65G User Manual page 15

Panasonic microcomputer user's manual

Advertisement

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

Advertisement

loading