APPENDIX A PROGRAM LIST
In that case, LED1 blinks every 120 ms even if SW is turned on.
<RESET source and LED2>
+------------------------+
| RESET Source | LED2 |
| | (P21) |
|----------------|-------|
| Other than WDT | OFF |
|----------------|-------|
| WDT | ON |
+------------------------+
<<I/O port settings>>
Input: P43
Output: P00-P03, P20-P23, P30-P33, P40-P42, P44-P47, P120-P123, P130
# All unused ports are set as the output mode.
*****************************************************************************/
/*============================================================================
Preprocessing directive (#pragma)
============================================================================*/
#pragma
SFR
/* SFR names can be described at the C
source level */
#pragma
EI
/* EI instructions can be described at the
C source level */
#pragma
NOP
/* NOP instructions can be described at
the C source level */
#pragma interrupt INTP1 fn_intp1
/* Interrupt function declaration:INTP1 */
/*****************************************************************************
Initialization after RESET
*****************************************************************************/
sreg unsigned char ucRESF;
/* 8-bit variable for reset source check
(high-speed internal RAM area) */
void hdwinit(void){
unsigned char ucCnt200us;
/* 8-bit variable for 200 us wait */
/*----------------------------------------------------------------------------
Detect low-v initialize the watchdog timer + set the clock
----------------------------------------------------------------------------*/
/* Initialize the watchdog timer */
WDTM = 0b01101111;
/* WDT overflow time = 2^20/fx = 131.07 ms
*/
/* Set the clock <1> */
PCC = 0b00000000;
/* The clock supplied to the CPU (fcpu) =
fxp (= fx/4 = 2 MHz) */
Application Note U18847EJ1V0AN
31