56F807 PWM problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

56F807 PWM problem

Jump to solution
3,626 Views
dingding
Contributor II
I need software control pwm output, and each channel works indepently. PWM frequence is 20k. But the pwmval couldn't be loaded, the pwm outputs always 3.3 V no matter how I change pwmval. The initial code as the following:
 
   PWMA_PMCTL=0x0000;
   PWMA_PMFCTL=0x0055;        //fault protection
   PWMA_PMDISMAP1=0;
   PWMA_PMDISMAP2=0;
   PWMA_PMOUT=0x0000;
   PWMA_PMCCR=0x8000; 
   PWMA_PMCCR|=0x0010;  //所有pwmvalx通道同时访问 
   PWMA_PMDCFG=0x100E;    //0100 0000 0000 1110   edge aligned
   PWMA_PMDEADTM=5;
    PWMA_PWMVAL0=1000;
   PWMA_PWMVAL1=1000;
   PWMA_PWMVAL2=1000;
   PWMA_PWMVAL3=1000;
   PWMA_PWMVAL4=1000;
   PWMA_PWMVAL5=1000;
   PWMA_PWMCM=4000;           //PWM周期20KHZ
    PWMA_PMCTL|=2;  //enable pwm  
I do these on 56F807EVM.
Help will be really appreciated!
0 Kudos
Reply
1 Solution
1,364 Views
ebiz_ws_prod
Contributor II

This an automatic process.

We are marking this post as solved, due to the either low activity or any reply marked as correct.
If you have additional questions, please create a new post and reference to this closed post.

NXP Community!

View solution in original post

0 Kudos
Reply
3 Replies
1,365 Views
ebiz_ws_prod
Contributor II

This an automatic process.

We are marking this post as solved, due to the either low activity or any reply marked as correct.
If you have additional questions, please create a new post and reference to this closed post.

NXP Community!

0 Kudos
Reply
1,364 Views
dingding
Contributor II
Thank you! I think I solved my problem.
0 Kudos
Reply
1,364 Views
hhx
Contributor I
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