EasyManua.ls Logo

Renesas V850 Series - Page 183

Renesas V850 Series
186 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 4 PROGRAM LIST
Application Note U17209EJ1V0AN
186
TMCD0 = 0x01; /* Supply clock to timer D0 */
TMCD0 |= 0x70; /* Select fXX/512 (3.2 uSEC) */
CMD0 = 10000 / 32; /* 10 mSEC */
TMCD0 |= 0x02; /* Start timer */
CMICD0 = 0x06;
/* Set motor control interrupt timer TMD1 */
TMCD1 = 0x00; /* Stop (reset) timer D1 */
TMCD1 = 0x01; /* Supply clock to timer D1 */
TMCD1 |= 0x70; /* Select fXX/512 (3.2 uSEC) */
CMD1 = TS * 10 / 32 ; /* 0.5 mSEC */
TMCD1 |= 0x02; /* Start timer */
CMICD1 = 0x02;
/* Set speed measuring timer TMENC10 */
TUM10 = 0x00;
TMC10 = 0x03;
PRM10 = 0x07; /* fXX (8 MHz*10/2)/256 (6.4 uSEC) */
TMC10 = 0x43; /* Start timer */
/* TMQ initialization */
TP2CTL0 = 0x00;
TQ0CTL0 = 0x00;
/* fXX/2 (80 MHz/2 = 40 MHz) */
TQ0CTL1 = 0x07; /* Select 6-phase PWM output mode */
TQ0IOC0 = 0x55; /* Positive phase normal output, output enabled */
TQ0IOC1 = 0x00; /* INTPQ0 to INTPQ3, EVTQ, and TIQ pins of */
TQ0IOC2 = 0x00; /* TMQ are not used */
TQ0OPT0 = 0x00; /* Select comparison mode */
TQ0CCR0 = PWM_DATA ; /* Carrier wave cycle 20 kHz */
TQ0CCR1 = PWM_INIT; /* Set U-phase duty to 10 */
TQ0CCR2 = PWM_INIT; /* Set V-phase duty to 10 */
TQ0CCR3 = PWM_INIT; /* Set W-phase duty to 10 */
pwm_value = PWM_DATA /2 ;
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 INTCCP20 */
/* interrupt during counting up */
/* A/D trigger output of INTCCP20 interrupt */
/* enabled */
TQ0IOC3 = 0x54; /* Negative phase normal output, output enabled */
PMC1 = 0x3F; /* Alternate-function mode */
PFCE1 = 0x00; /* Select TOQT1 to TOQT3 or TOQB1 to TOQB3 output */
PFC1 = 0x3F;
HZA0CTL1 = 0x00;
HZA0CTL1 = 0xD0; /* High-impedance operation enabled */
/* INTP000 pin rising edge valid */
TP2CTL0 |= 0x80;
TQ0CTL0 |= 0x80; /* Start 6-phase PWM output mode */

Table of Contents