Programming Example
8-22 ADSP-21368 SHARC Processor Hardware Reference
/* 1. Configure frequency */
ustat3=fPWM; /* fPCLK/2xfPWM */
dm(PWMPERIOD0)=ustat3; /* PWM Period Register for switching
frequency (unsigned integer) */
/* 2. Configure duty cycles Width=[period/2] + duty program in
the two’s-complement of the high side width for individual con-
trol this only programs AH signal. If PWMAL0 is not programmed
then the AL and AH signals have the same duty cycle */
ustat3=0; /* PWM Channel A Duty Control
(two’s-complement integer) */
dm(PWMA0)=ustat3; /* Set up the duty cycle register to 0
(50% duty cycle) */
ustat3 = 0x63C; /* two’s-complement of 0x9C4 = 0x63C - 80%
high - 20% low */
dm(PWMAL0)=ustat3; /* PWM Channel AL Duty Control */
/* 3. Configure Dead Time */
ustat3=0x0; /* PWM Dead Time Register (unsigned integer) */
dm(PWMDT0)=ustat3;
/* 4. Configure Polarity (this can be changed on the fly
after the PWM port is enabled) */
ustat3=0; /* PWM Polarity Select Register */
bit set ustat3 PWM_POL1AL | PWM_POL1AH; /* Enables high polarity
A output /*
dm(PWMPOL0)=ustat3;
PWM_setup.end: nop;