![NEC 78K0S/K 1+ Series Скачать руководство пользователя страница 41](http://html.mh-extra.com/html/nec/78k0s-k-1-series/78k0s-k-1-series_application-note_249252041.webp)
APPENDIX A PROGRAM LIST
Application Note U18752EJ2V0AN
41
/*****************************************************************************
Initialization after RESET
*****************************************************************************/
void hdwinit(void){
/*----------------------------------------------------------------------------
Initialize the watchdog timer
----------------------------------------------------------------------------*/
WDTM = 0b01110111;
/* Stop the watchdog timer operation */
/*----------------------------------------------------------------------------
Initialize the clock generators
----------------------------------------------------------------------------*/
PPCC = 0b00000010;
/* The clock supplied to the peripheral */
/* hardware (fxp) = fx/4 (= 2MHz) */
PCC = 0b00000000;
/* The clock supplied to the CPU (fcpu) = */
/* fxp (= 2MHz) */
LSRCM = 0b00000001;
/* Stop the low-speed internal oscillator */
/*----------------------------------------------------------------------------
Initialize the port 0
----------------------------------------------------------------------------*/
PM0 = 0b11110000;
/* Set P00-P03 as output mode */
P0 = 0b00000000;
/* Set output latches of P00-P03 as low */
/*----------------------------------------------------------------------------
Initialize the port 2
----------------------------------------------------------------------------*/
PM2 = 0b11110000;
/* Set P20-P23 as output mode */
P2 = 0b00000111;
/* Set output latches of P20-P22 as high, */
/* P23 as low */
/*----------------------------------------------------------------------------
Initialize the port 3
----------------------------------------------------------------------------*/
PM3 = 0b11110000;
/* Set P30-P33 as output mode */
P3 = 0b00000000;
/* Set output latches of P30-P33 as low */
/*----------------------------------------------------------------------------
Initialize the port 4
----------------------------------------------------------------------------*/
PM4 = 0b00001001;
/* Set P40 and P43 as input mode, P41, */
/* P42 and P44-P47 as output mode */
PU4 = 0b00001001;
/* Connect on-chip pull-up resistors to */
/* P40 and P43 */
P4 = 0b00000000;
/* Set output latches of P41, P42 and */
/* P44-P47 as low */
/*----------------------------------------------------------------------------
Initialize the port 12
----------------------------------------------------------------------------*/
PM12 = 0b11110000;
/* Set P120-P123 as output mode */
P12 = 0b00000000;
/* Set output latches of P120-P123 as */
/* low */
/*----------------------------------------------------------------------------
Initialize the port 13