Panasonic MN103S manual Example program, Enable the interrupt

Page 18

Chapter 3

Microcomputer Basics 1

Example program

/************************************************************************/

/*

CHECK Program for The count of the rising edge

*/

/*

which used event count operation(8-bit)

*/

/************************************************************************/

/*

Setting of Main Peripheral

 

*/

/*

Port 0 : Unused

 

 

*/

/*

Port 1 : Unused

 

 

*/

/*

Port 2 : Unused

 

 

*/

/*

Port 3 : Used as Timer 1 input

 

*/

/*

Port 4 : Used as output port

 

*/

/*

Port 5 : Unused

 

 

*/

/*

Port 6 : Unused

 

 

*/

/*

Port 7 : Unused

 

 

*/

/*

Port 8 : Unused

 

 

*/

/*

Timer 0 : Unused

 

 

*/

/*

Timer 1 : Used as Event count operation

*/

/*

Timer 2 : Unused

 

 

*/

/*

Timer 3 : Unused

 

 

*/

/*

Timer 8 : Unused

 

 

*/

/*

Timer 11 : Unused

 

*/

/*

3-phase PWM output : Unused

 

*/

/*

Serial interface communication 2 : Unused

*/

/*

10-bit A/D converters : Unused

 

*/

/*

 

 

 

 

*/

/*

Interrupt : External interrupt

Unused

*/

/*

 

 

 

 

*/

/*

2004/09

Rev 0.1

 

*/

/************************************************************************/

#include "sr103s92.h"

 

 

#include "int.h"

 

 

 

/****************************/

 

 

/*

Declaration of function */

 

 

/****************************/

 

 

void main(void);

 

 

 

void initialize(void);

 

 

/*

-----------------------------------------------After the assembler boot processing is completed

 

 

control is shifted to this main routine.

 

void-----------------------------------------------main(void)

*/

 

 

 

{

initialize();

 

/* Initial Job */

 

 

 

 

 

TM1MD

= 0x00;

 

/* Stop the counter */

 

/*-----------------------------------------------

-----------------------------------------------P4 setting

 

 

 

 

 

 

*/

 

 

P4OUT = 0x00;

 

/* Set P44 Low(VSS level) */

 

 

P4DIR = 0x10;

 

/* Set P44 output */

 

/*-----------------------------------------------

-----------------------------------------------P3 setting

 

 

 

 

 

 

*/

 

 

P3MD

= 0x02;

 

/* Set TM1IO port */

 

 

P3DIR = 0x00;

 

/* Set P31 input */

 

/*-----------------------------------------------

-----------------------------------------------Event count timer setting

 

 

 

 

TM1BR

= 0x04;

 

/* Set the base register */

 

 

TM1MD

= TM1MD 0x07;

/* Select the clock source to TMIN1 pin input */

 

TM1MD

= TM1MD 0x40;

/* Initial timer */

 

 

TM1MD

= TM1MD & 0xBF;

/* Set normal operation */

 

 

G4ICR = 0x0200;

 

/* Set an interrupt level */

 

 

 

 

 

/* Enable the interrupt */

 

 

asm ("

or

0x0F00,PSW\n"); /* Enable the interrupt, Interrupt level 7 */

III−42 8-bit timer operation

Image 18
Contents MN103S927/92A/F92G LSI Application Notes Excerption Page Page About This Manual Format used for sample program explanations About This Manual3 Page Table of Contents Microcomputer Basics Chapter overview Appendix Table of Contents Counting rising edges using the event count OverviewHardware allocation list Timer 1 Base Register TM1BR 0x0000A149 Timer 1 Binary Counter TM1BC 0x0000A151 Timer 1 Mode Register TM1MD 0x0000A141Port 3 I/O Control Register P3DIR 0x0000A023 Port 3 Output Mode Register P3MD 0x0000A033 Flowchart ENDEnable the interrupt Example programCpum Inquiries URL http//panasonic.co.jp/semicon/e-micom/inquirySales Offices