void PWM1_Init(void)
{
RatioStore = 65509; /* Store initial value of the ratio */
/* PWMA_PMDISMAP1: DISMAP=0 */
setReg(PWMA_PMDISMAP1,0); /* Set up PWM Disable Mapping Register 1 */
/* PWMA_PMDISMAP2: DISMAP=0 */
setReg(PWMA_PMDISMAP2,0); /* Set up PWM Disable Mapping Register 2 */
/* PWMA_PMOUT: PAD_EN=0,??=0,OUTCTL=63,??=0,??=0,OUT=63 */
setReg(PWMA_PMOUT,16191); /* Set up Output Control Register */
setReg(PWMA_PMDEADTM,0); /* Set up Dead-Time Register */
/* PWMA_PMCCR: ENHA=0,??=0,MSK=63,??=0,??=0,VLMODE=0,??=0,SWP45=0,SWP23=0,SWP01=0 */
setReg(PWMA_PMCCR,16128); /* Set up PWM Chanel Control Register */
/* PWMA_PMCFG: ??=0,??=1,??=0,EDG=0,??=0,TOPNEG45=0,TOPNEG23=0,TOPNEG01=1,??=0,BOTNEG45=0,BOTNEG23=0,BOTNEG01=1,INDEP45=0,INDEP23=0,INDEP01=0,WP=0 */
setReg(PWMA_PMCFG,4110); /* Set up PWM configure register */
setReg(PWMA_PMCNT,0); /* Reset counter */
setRegBits(PWMA_PMCFG,256); /* Set polarity in the PWM configure register */
EnUser = TRUE; /* Enable device */
setReg(PWMA_PWMVAL0,2499); /* Store initial value to the duty-compare register */
setReg(PWMA_PWMCM,2500); /* and to the period register */
SetPV(3); /* Set prescaler register according to the selected high speed CPU mode */
}
static void SetRatio(void)
{
setReg(PWMA_PWMVAL0,((getReg(PWMA_PWMCM)+1) * (dword)RatioStore) >> 16); /* Calculate new value according to the given ratio */
setRegBit(PWMA_PMCTL,LDOK); /* Load counter and modulo registers into buffers */
}
try this