CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
161
HZA0CTL0 |= 0x08 ; /* PWM output off */
error_flag = ERR_NO1 ; /* Set error No. */
}
}
4.4.11 Hardware initialization processing function
/****************************************************************************** /
/* Hardware (peripheral I/O) initialization */
/****************************************************************************** /
void hinit( void )
{
/* Port mode register initialization */
PM3 = 0xfe ;
PM4 = 0xff ;
PMDL = 0x0000 ;
OUT_data( LED11, 0xff ) ; /* LED OFF */
OUT_data( LED12, 0xff ) ;
OUT_data( LED13, 0xff ) ;
OUT_data( LED14, 0xff ) ;
OUT_data( LED21, 0xff ) ;
OUT_data( LED22, 0xff ) ;
OUT_data( LED31, 0xff ) ;
OUT_data( LED32, 0xff ) ;
OUT_data( LED41, 0xff ) ;
OUT_data( LED42, 0xff ) ;
/* Set 10 mSEC timer TMP0 */
TP0CTL0 = 0x05 ; /* Select fXX/64 */
TP0CTL1 = 0x00 ; /* Select interval timer mode */
TP0CCR0 = 10000 ; /* 10 mSEC */
TP0CTL0 |= 0x80 ; /* Start timer */
TP0CCIC0= 0x06;
/* Set motor control interrupt timer TMP1 */
TP1CTL0 = 0x05 ; /* Select fXX/64 */
TP1CTL1 = 0x00 ; /* Select interval timer mode */
TP1CCR0 = TS ; /* TS uSEC */
TP1CTL0 |= 0x80 ; /* Start timer */
TP1CCIC0= 0x01;
/* Set speed measuring timer TMP2 */
TP2CTL0 = 0x05 ; /* Select fXX/64 */
TP2CTL1 = 0x05 ; /* Select free-running timer mode */
TP2CTL0 |= 0x80 ; /* Start timer */
/* TMQ initialization */
TQ0CTL0 = 0x00; /* fXX/2 (64 MHz/2 = 32 MHz) */
TQ0CTL1 = 0x07; /* Select 6-phase PWM output mode */
TQ0IOC0 = 0x55; /* Positive phase normal output, output enabled */
TQ0IOC1 = 0x00; /* TIQ00 to TIQ03, EVTQ0, and TRGQ0 pins of TMQ */