MC56F8006 PWM generator

cancel
Showing results for 
Search instead for 
Did you mean: 

MC56F8006 PWM generator

1,137 Views
edjiang
Contributor II

Hi,

 

I need to generator 6-channel PWM outputs in complementary mode. This is my first time using MC56F8006 and I didn't find any app-note on this. Does anyone have a simple example of PWM generation? So that I can take reference and modify it according to my application. Thanks in advance!

 

Ed

Labels (1)
Tags (2)
0 Kudos
7 Replies

374 Views
khalil001
Contributor II

I am using the MC56F8006 to generate PWM now, and I have the same issue.

Have you solve this issue?

Could you see the PWM waveform on the corresponding output pins?

Could you help me? Thank you very much!

0 Kudos

374 Views
CarlosCba
Contributor II

Hi Ed,

I new with the MC56F8006 and I have the same issue. Could you do your code work? Can you post it?

Thanks in advance.

Best regards,

0 Kudos

374 Views
khalil001
Contributor II

I am using the MC56F8006 to generate PWM now, and I have the same issue.

Have you solve this issue?

Could you see the PWM waveform on the corresponding output pins?

Could you help me? Thank you very much!

0 Kudos

374 Views
peter_pinewski
NXP Employee
NXP Employee

If you are using Codewarrior, you can get example code through processor expert.  Note, the MC56F8006 has the same PWM as other DSC devices such as 56F8013. 

Here is an example of the PWM intialization in processor expert for complementary PWM on the 56F8013

** ===================================================================

**     Method      :  PWM1_Init (component Init_PWM)

**

**     Description :

**         Peripheral Initialization Beans provide a low-level

**         hardware approach to initialize registers of the

**         peripheral module. They are intended for experienced

**         users.

**     Parameters  : None

**     Returns     : Nothing

** ===================================================================

*/

void PWM1_Init(void)

{

  /* PWM_PMCTL: LDFQ=1,HALF=0,IPOL2=0,IPOL1=0,IPOL0=0,PRSC=0,PWMRIE=0,PWMF=0,??=0,??=0,LDOK=0,PWMEN=0 */

  setReg16(PWM_PMCTL, 4096U);          

  /* PWM_PMFCTL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=0,FMODE0=0 */

  setReg16(PWM_PMFCTL, 0U);            

  /* PWM_PWMCM: ??=0,CM=800 */

  setReg16(PWM_PWMCM, 800U);           

  /* PWM_PWMVAL0: VAL=400 */

  setReg16(PWM_PWMVAL0, 400U);         

  /* PWM_PWMVAL1: VAL=400 */

  setReg16(PWM_PWMVAL1, 400U);         

  /* PWM_PWMVAL2: VAL=400 */

  setReg16(PWM_PWMVAL2, 400U);         

  /* PWM_PWMVAL3: VAL=400 */

  setReg16(PWM_PWMVAL3, 400U);         

  /* PWM_PWMVAL4: VAL=400 */

  setReg16(PWM_PWMVAL4, 400U);         

  /* PWM_PWMVAL5: VAL=400 */

  setReg16(PWM_PWMVAL5, 400U);         

  /* PWM_PMDISMAP1: DISMAP=4369 */

  setReg16(PWM_PMDISMAP1, 4369U);      

  /* PWM_PMDISMAP2: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,DISMAP=17 */

  setReg16(PWM_PMDISMAP2, 17U);        

  /* PWM_PMDEADTM0: ??=0,??=0,??=0,??=0,PWMDT0=32 */

  setReg16(PWM_PMDEADTM0, 32U);        

  /* PWM_PMDEADTM1: ??=0,??=0,??=0,??=0,PWMDT1=32 */

  setReg16(PWM_PMDEADTM1, 32U);        

  /* PWM_PMCCR: ENHA=0,nBX=0,MSK=0,??=0,??=0,VLMODE=0,??=0,SWP45=0,SWP23=0,SWP01=0 */

  setReg16(PWM_PMCCR, 0U);             

  /* PWM_PMOUT: PAD_EN=0,??=0,OUTCTL=0,??=0,??=0,OUT=0 */

  setReg16(PWM_PMOUT, 0U);             

  /* PWM_PMICCR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,ICC2=0,ICC1=0,ICC0=0 */

  setReg16(PWM_PMICCR, 0U);            

  /* PWM_PMSRC: ??=0,??=0,CINV5=0,CINV4=0,CINV3=0,CINV2=0,CINV1=0,CINV0=0,SRC2=0,SRC1=0,SRC0=0 */

  setReg16(PWM_PMSRC, 0U);             

  /* PWM_PMCFG: ??=0,DBG_EN=0,WAIT_EN=0,EDG=0,??=0,TOPNEG45=0,TOPNEG23=0,TOPNEG01=0,??=0,BOTNEG45=0,BOTNEG23=0,BOTNEG01=0,INDEP45=0,INDEP23=0,INDEP01=0,WP=0 */

  setReg16(PWM_PMCFG, 0U);             

  /* PWM_PMFSA: FPIN3=0,FFLAG3=0,FPIN2=0,FFLAG2=0,FPIN1=0,FFLAG1=0,FPIN0=0,FFLAG0=0,??=0,FTACK3=1,DT5=0,DT4_FTACK2=1,DT3=0,DT2_FTACK1=1,DT1=0,DT0_FTACK0=1 */

  setReg16(PWM_PMFSA, 85U);            /* clear fault flags */

  /* PWM_PMFCTL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=1,FMODE0=0 */

  setReg16(PWM_PMFCTL, 2U);            

  /* PWM_PMCTL: LDOK=1 */

  setReg16Bits(PWM_PMCTL, 2U);         /* set LDOK bit */

  /* PWM_PMCTL: PWMEN=1 */

  setReg16Bits(PWM_PMCTL, 1U);         /* set PWMEN bit */

  /* PWM_PMCTL: PWMF=0 */

  clrReg16Bits(PWM_PMCTL, 16U);        /* clear PWMF flag */

}

/* END PWM1. */

0 Kudos

374 Views
edjiang
Contributor II

Hi Peter,

Thanks for your reply. Yes I am using CodeWarrior, but I am not familiar with so call processor expert. I modify the code you post and also enable the PAD_EN so I can measure the PWM with a oscilloscope. Unfortunately, I didn't see the PWM waveform on the corresponding output pins. I attach the complete code. What can be the problem in the code?

Ed

#include "CPU.h"

#include "MC56F8006.h"

typedef unsigned int word;

#define setReg16(RegName,val) (RegName = (word)(val))

#define setReg16Bits(RegName, SetMask)                           (RegName |= (word)(SetMask))

#define clrReg16Bits(RegName, ClrMask)                           (RegName &= (word)(~(word)(ClrMask)))

void PWM1_Init(void);

void PWM1_Init(void)

{

  /* PWM_PMCTL: LDFQ=1,HALF=0,IPOL2=0,IPOL1=0,IPOL0=0,PRSC=0,PWMRIE=0,PWMF=0,??=0,??=0,LDOK=0,PWMEN=0 */

  setReg16(PWM_CTRL, 4096U);         

  /* PWM_PMFCTL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=0,FMODE0=0 */

  //setReg16(PWM_PMFCTL, 0U);           

  /* PWM_PWMCM: ??=0,CM=800 */

  setReg16(PWM_CMOD, 800U);          

  /* PWM_PWMVAL0: VAL=400 */

  setReg16(PWM_VAL0, 400U);        

  /* PWM_PWMVAL1: VAL=400 */

  setReg16(PWM_VAL1, 400U);        

  /* PWM_PWMVAL2: VAL=400 */

  setReg16(PWM_VAL2, 400U);        

  /* PWM_PWMVAL3: VAL=400 */

  setReg16(PWM_VAL3, 400U);        

  /* PWM_PWMVAL4: VAL=400 */

  setReg16(PWM_VAL4, 400U);        

  /* PWM_PWMVAL5: VAL=400 */

  setReg16(PWM_VAL5, 400U);        

  /* PWM_PMDISMAP1: DISMAP=4369 */

  setReg16(PWM_DMAP1, 4369U);     

  /* PWM_PMDISMAP2: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,DISMAP=17 */

  setReg16(PWM_DMAP2, 17U);       

  /* PWM_PMDEADTM0: ??=0,??=0,??=0,??=0,PWMDT0=32 */

  setReg16(PWM_DTIM0, 32U);       

  /* PWM_PMDEADTM1: ??=0,??=0,??=0,??=0,PWMDT1=32 */

  setReg16(PWM_DTIM1, 32U);       

  /* PWM_PMCCR: ENHA=0,nBX=0,MSK=0,??=0,??=0,VLMODE=0,??=0,SWP45=0,SWP23=0,SWP01=0 */

  setReg16(PWM_CCTRL, 0U);            

  /* PWM_PMOUT: PAD_EN=0,??=0,OUTCTL=0,??=0,??=0,OUT=0 */

  setReg16(PWM_OUT, PWM_OUT_PAD_EN);            

  /* PWM_PMICCR: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,ICC2=0,ICC1=0,ICC0=0 */

  setReg16(PWM_ICCTRL, 0U);           

  /* PWM_PMSRC: ??=0,??=0,CINV5=0,CINV4=0,CINV3=0,CINV2=0,CINV1=0,CINV0=0,SRC2=0,SRC1=0,SRC0=0 */

  setReg16(PWM_SCTRL, 0U);            

  /* PWM_PMCFG: ??=0,DBG_EN=0,WAIT_EN=0,EDG=0,??=0,TOPNEG45=0,TOPNEG23=0,TOPNEG01=0,??=0,BOTNEG45=0,BOTNEG23=0,BOTNEG01=0,INDEP45=0,INDEP23=0,INDEP01=0,WP=0 */

  //setReg16(PWM_PMCFG, 0U);            

  /* PWM_PMFSA: FPIN3=0,FFLAG3=0,FPIN2=0,FFLAG2=0,FPIN1=0,FFLAG1=0,FPIN0=0,FFLAG0=0,??=0,FTACK3=1,DT5=0,DT4_FTACK2=1,DT3=0,DT2_FTACK1=1,DT1=0,DT0_FTACK0=1 */

  setReg16(PWM_FLTACK, 85U);            /* clear fault flags */

  /* PWM_PMFCTL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=1,FMODE0=0 */

  setReg16(PWM_FCTRL, 2U);           

  /* PWM_PMCTL: LDOK=1 */

  setReg16Bits(PWM_CTRL, 2U);         /* set LDOK bit */

  /* PWM_PMCTL: PWMEN=1 */

  setReg16Bits(PWM_CTRL, 1U);         /* set PWMEN bit */

  /* PWM_PMCTL: PWMF=0 */

  clrReg16Bits(PWM_CTRL, 16U);        /* clear PWMF flag */

}

/* END PWM1. */

int main(void)

{

  PWM1_Init();

  for(;;)

  {

  }   

   

}

0 Kudos

374 Views
edjiang
Contributor II

my target name is: SDM_pFlash

0 Kudos

374 Views
edjiang
Contributor II

this is my code which doesn't work.

///////////////////////////////////////////////////////////////

void main(void)

{

   PWM_CMOD = 1000; // in this application,it's period of PWM, i.e. Time

   PWM_CNFG = 0; //center-aligned complementary PWM

   PWM_DTIM0 = 0x08;//deadtime insert

   PWM_DTIM1 = 0x08;

   PWM_OUT = PWM_OUT_PAD_EN;

   PWM_ICCTRL = PWM_ICCTRL_ICC2 | PWM_ICCTRL_ICC1 | PWM_ICCTRL_ICC0;

   //pulse_width = PWM_MODULO / 100 * duty_cycle ;

   PWM_VAL0 = 100;

   PWM_VAL1 = 800;

   PWM_VAL2 = 100;

   PWM_VAL3 = 800;

   PWM_VAL4 = 100;

   PWM_VAL5 = 800;

   PWM_CTRL = PWM_CTRL_LDOK;

   PWM_CTRL |= PWM_CTRL_PWMEN;

  for(;;)

  {

  }

}

///////////////////////////////////////////////////////////////

0 Kudos