CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
162
TQ0IOC2 = 0x00; /* are not used */
TQ0OPT0 = 0x00; /* Select comparison mode */
TQ0CCR0 = PWM_DATA ; /* Carrier wave cycle 20 kHz */
TQ0CCR1 = PWM_DATA /2; /* Set U-phase duty to 50 */
TQ0CCR2 = PWM_DATA /2; /* Set V-phase duty to 50 */
TQ0CCR3 = PWM_DATA /2; /* Set W-phase duty to 50 */
pwm_value = PWM_DATA /2 ;
TQ0DTC = 180; /* Dead time 6 uSEC */
TQ0OPT1 = 0x00; /* No culling, no crest and valley interrupts are used */
TQ0OPT2 = 0x04; /* • No culling between reloads */
/* • Clear and re-count dead time counter */
/* • Output A/D trigger output of INTTP2CC0 interrupt */
/* during counting up */
/* • A/D trigger output of INTTP2CC0 interrupt enabled */
TQ0IOC3 = 0xfc; /* Negative phase inverted output, output enabled */
PMC1 = 0x3F; /* Alternate-function mode */
PFCE1 = 0x00; /* Select TOQ0T1 to TOQ0T3 or TOQ0B1 to TOQ0B3 output */
PFC1 = 0x00;
HZA0CTL0 = 0x00;
HZA0CTL0 = 0xD0; /* High-impedance operation enabled */
/* TOQ0OFF pin rising edge valid */
HZA2CTL0 = 0x00; /* High-impedance off due to analog input */
TQ0CTL0 |= 0x80; /* Start 6-phase PWM output mode */
/* Set A/D */
ADA0M0 = 0x30 ; /* ANI00, ANI01 */
ADA0M1 = 0x01 ;
ADA0S = 0x05 ;
OP0CTL0 = 0x11 ; /* Operational amplifier gain 5 times */
OP0CTL1 = 0x11 ; /* Comparator valid */
AD0IC = 0x03 ;
ADA1M0 = 0x20 ; /* ANI13 */
ADA1M1 = 0x01 ;
ADA1S = 0x03 ;
OP1CTL0 = 0x00 ; /* Operational amplifier invalid */
OP1CTL1 = 0x00 ; /* Comparator invalid */
AD1IC = 0x03 ;
/* Set zero-cross signal interrupt pin */
PMC0 = 0x1c ;
INTR0 = 0x1c ; /* INTP2, INTP3, INTP4 both-edge interrupt */
INTF0 = 0x1c ;
PIC2 = 0x01 ;
PIC3 = 0x01 ;
PIC4 = 0x01 ;
}