NEC 78K0S/K 1+ Series Application Note page 21

External event counter
Hide thumbs Also See for 78K0S/K 1+ Series:
Table of Contents

Advertisement

(2) C language
#define eventCnt 10
void hdwinit(void){
unsigned char ucCnt200us;
Setting the external
event counter
compare value
CRC00 = 0b00000000;
CR000 = eventCnt-1;
Setting the count
clock
PRM00 = 0b00000011;
TI000 pin */
Starting timer
TOC00 = 0b00000000;
operation
TMC00 = 0b00001100;
match between TM00 and CR000) */
IF0
TMMK000 = 0;
return;
}
void main(void){
EI();
while (1){
}
}
__interrupt void fn_inttm000(){
P4 ^= 0b00000001;
return;
}
Figure 4-5. External Event Counter Operation Timing Chart Example (in the Case of This Sample Program Source)
Starts timer operation
TI000 pin input
TM00
CR000
INTTM000
P40 output
CHAPTER 4 SETTING METHODS
Setting the operation mode of
CR000 as a compare register
= 0x00;
Enabling
INTTM000
interrupt
servicing
NOP();
NOP();
Starting
interrupt servicing
by INTTM000
interrupt
generation
Starts counting (after the valid edge is detected twice)
1
2
3
0
1
2
3
9
LED is turned off
/* Timer 00 external event counter compare value */
/* 8-bit variable for 200 us wait */
/* Use CR000 as a compare register */
/* Initialize the compare value */
/* Set the count clock as the falling edge of the
/* Do not perform timer output */
/* Start the timer operation (clear & start upon a
/* Clear invalid interrupt requests in advance */
/* Unmask INTTM000 interrupts */
Clearing the
INTTM000
interrupt request
flag
/* Enable vector interrupt */
/* Reverse the LED output */
7
8
9
0
1
2
LED is turned on
Application Note U18888EJ1V0AN
3
4
8
9
0
LED is turned off
1
2
3
21

Advertisement

Table of Contents
loading

This manual is also suitable for:

78k0s/ka1+78k0s/kb1+78k0s/ku1+78k0s/ky1+

Table of Contents