Download Print this page

Panasonic PanaXSeries MN103S65G User Manual page 13

Panasonic microcomputer user's manual

Advertisement

2-4 A 8-bit 16-bit timer, a peripheral initial
#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
/***********************************************
* Interval timer by 8-bit timer
* Pre-scaler 0 is used, and the cascade connection of the timers 0
* and 1 is carried out, and it is used as a 16-bit timer.
***********************************************/
void initInterval8( void )
{
unsigned short data0,data1;
TM03PSC = PS0MD_STOP;
TM0MD = TM0MD_STOP;
TM1MD = TM1MD_STOP;
/* Setup of timer cycles/min ratio 60000-1 */
TM0BR = TM0_COUNT0x5f;
TM1BR = TM1_COUNT0xea;
data0 = 0;
TM0MD = data0;
data1 = TM1MD_LOAD2;
TM1MD = data1;
data0 |= TM0MD_START1;
TM0MD = data0;
data1 |= TM1MD_START1;
TM1MD = data1;
data0 &= ~TM0MD_START1;
TM0MD = data0;
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
/* load cycles/min ratio*/
/* stabilization */
/* timer start */
/* timer permission*/
/* cycles/min setup (200 cycles/min-1) */
/* cycles/min setup (0xea5f = 0xea60(60000) - 1) */
/* cycles/min setup (0xea5f = 0xea60(60000) - 1) */
0x42
/* read cycles/min ratio */
/* clock source (pre-scaler 0 clock ) setup */
0x03
/* timer 0 and cascade connection*/
/* stabilization*/
/* stabilization*/
/* timer start*/
/* timer start */
/* pre-scaler stop*/
/* timer stop*/
/* timer stop*/
/* cycles/min setup
/* cycles/min setup*/
/* Arbitrary setup */
/* timer 0 and cascade setup */
/* Timer 0 initialization LDE=1 */
/* Timer 1 initialization LDE=1 */
/* Timer 0 start LDE=0 */
2-36
0xea5f=59999 */

Advertisement

loading