16 bit PWM with eMIOS

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

16 bit PWM with eMIOS

1,782件の閲覧回数
kevinschmidt
Contributor I

Hey guys,

 

I'm trying to implement a 16 bit pwm by using emios on a MPC563x. The PWM frequency is to have 100 kHz, the system frequency is given with 80MHz. Reading all the official examples I'm somehow stuck how to continue on that matter.

Initializing the emios module and setting up a pwm with a given frequency works well.

 

  EMIOS.MCR.B.GPRE= 7;     /* Divide 80 MHz sysclk by 7+1 = 10 for 10MHz eMIOS clk*/

  EMIOS.MCR.B.ETB = 0;      /* External time base is disabled */

  EMIOS.MCR.B.GPREN = 1; /* Enable eMIOS clock */

  EMIOS.MCR.B.GTBE = 1;  /* Enable global time base */

  EMIOS.MCR.B.FRZ = 1;  /* Enable stopping channels when in debug mode */

 

/* EMIOS CH 2: Output Pulse Width & Freq Modulation*/

/* Provide 100kHz output (10usec period) */

/* Input clock is eMIOS clk of 10MHz (0.1 usec period)*/

EMIOS.CH[2].CBDR.R = 99; /* Period = 0.1 usec x (99+1) = 10 usec, 100kHz*/

EMIOS.CH[2].CADR.R = 19; /* Duty cycle = 0.1 usec x (19+1) = 2 usec (20%) */

EMIOS.CH[2].CCR.B.UCPRE = 0; /* Channel counter uses divide by (0+1) prescaler */

EMIOS.CH[2].CCR.B.UCPREN = 1; /* Channel counter's prescaler is loaded & enabled*/

EMIOS.CH[2].CCR.B.EDPOL = 1; /* Polarity is active high */

EMIOS.CH[2].CCR.B.MODE= 0x19; /* Mode= 0PWFM, next period update, flag on B match*/

SIU.PCR[181].B.PA = 3; /* Initialize pad for eMIOS channel. */

SIU.PCR[181].B.OBE = 1; /* Initialize pad AC16 for output */

 

But how to include a variable 16 bit duty cycle by keeping the same frequency? The system clk is divided and results in the emios clk. The latter, is used to increment until the value of register CBDR is reached. When this is true, CBDR should have a value of 2^16. When doing so the required sys clk increases dramatically. So where's the solution? Am I missing something completely?

 

Cheers,

Kev

 

 

ラベル(1)
タグ(3)
0 件の賞賛
0 返答(返信)