Hi,

I would like to produce asymmetrical waveform for ADSP-BF609 PWM module with PULSEMODE 01,

Can anyone help me in determining PWM_AH0 and PWM_AH1 values for 25% dutycycle.

Suppose fPwm=10KHz, PWM_TM0=5000

Thanks in advance

Hi,

I would like to produce asymmetrical waveform for ADSP-BF609 PWM module with PULSEMODE 01,

Can anyone help me in determining PWM_AH0 and PWM_AH1 values for 25% dutycycle.

Suppose fPwm=10KHz, PWM_TM0=5000

Thanks in advance

- 1 person found this helpful
Hi,

In order to produce asymmetrical waveform, using the Pulse mode 01, you have to program different values in

PWM_AH0 and PWM_AH1 registers.

For PWM_TM0=5000, programming these registers to '0' will result in a symmetric waveform with 50 % duty cycle. Next programming a value of '-1250'(signed integer) to each PWM_AH0 and PWM_AH1 will result in 25%duty symmetrical waveform. Now for asymmetrical waveform, if say PWM pulse has to be lying more towards first half of PWM period then, programming PWM_AH0 = -1000 ; and PWM_AH1 = -1500 ; will achieve that(Assuming the dead time is 0 in all cases).

Hope it helps.

Regards,

Nabeel

PWM Settings:

fsclk = 100MHz

fpwm = 10KHz

tpwm = 100 µ s

PWM_TM0= 5000

According to Autosar Standards, Dutycycle scaling is

0x0000(0d) for 0% Dutycycle

0x8000(32768d) for 100% DutyCycle

It is for normal linear timer counts.

So accordingly in we call void Pwm_SetDutyCycle( Pwm_ChannelType ChannelNumber,uint16 DutyCycle) API

here only parameter to pass is channel number and dutycycle.

But only one value of dutycycle is to be passed according to formula,

AbsoluteDutyCycle = ((uint32)AbsolutePeriodTime * RelativeDutyCycle) >> 15;

i.e Absolute period time is nothing but PWM_TM value in our case and relative dutycycle is the passing parameter.

say 0x0000 for 0% Dutycycle

0x2000 for 25% Dutycycle

0x4000 for 50% Dutycycle

0x6000 for 75% Dutycycle

0x8000 for 100% Dutycycle

So accordingly,

For 0% Dutycycle, AbsoluteDutyCycle = (5000d*0x0000)>>15 = 0

For 25% Dutycycle, AbsoluteDutyCycle = (5000d*0x2000)>>15 = 1250

For 50% Dutycycle, AbsoluteDutyCycle = (5000d*0x4000)>>15 = 2500

For 75% Dutycycle, AbsoluteDutyCycle = (5000d*0x6000)>>15 = 3750

For 100% Dutycycle, AbsoluteDutyCycle = (5000d*0x8000)>>15 = 5000

But ADSP-BF609 is UP-Down counter and scaling is -PWM_TM/2 to +PWM_TM/2

Accordingly dutycycle formula is recalculated to our ADI scaling as,

AbsoluteDutyCycle = (((uint32)AbsolutePeriodTime * RelativeDutyCycle) >> 15) - ((uint32)AbsolutePeriodTime/2)

i.e Absolute period time is nothing but PWM_TM value in our case and relative dutycycle is the passing parameter.

say 0x0000 for 0% Dutycycle

0x2000 for 25% Dutycycle

0x4000 for 50% Dutycycle

0x6000 for 75% Dutycycle

0x8000 for 100% Dutycycle

So accordingly,

For 0% Dutycycle, AbsoluteDutyCycle = ((5000d*0x0000)>>15)-(5000/2) = -2500 (Load it in PWM_AHO for PULSEMODE 00)

For 25% Dutycycle, AbsoluteDutyCycle =((5000d*0x2000)>>15)-(5000/2) = -1250 (Load it in PWM_AHO for PULSEMODE 00)

For 50% Dutycycle, AbsoluteDutyCycle =((5000d*0x4000)>>15)-(5000/2) = 0 (Load it in PWM_AHO for PULSEMODE 00)

For 75% Dutycycle, AbsoluteDutyCycle =((5000d*0x6000)>>15)-(5000/2) = +1250 (Load it in PWM_AHO for PULSEMODE 00)

For 100% Dutycycle, AbsoluteDutyCycle =((5000d*0x8000)>>15)-(5000/2)= +2500 (Load it in PWM_AHO for PULSEMODE 00)

For PULSEMODE 00 we can load the above calculated values and we can obtain required dutycycle.

Now for PULSEMODE = 01,10,11 how to load PWM_AH0 and PWM_AH1 values.

Should we keep PWM_AH0 fixed and calculate PWM_AH1 according to formula?

If yes, please can you help in determining PWM_AH1 based on fixed PWM_AH0

Regards,

Kishore K

Hi,

Thanks for detailing how you are obtaining the register values for different duty cycles.

But just to check back as per you calculation, for 25% duty the values come as -1250 for 00 mode which matches with what I suggested in my earlier post. So -1500 and -1000 should have resulted in 25% duty. I am not sure why you are getting only 10 % duty with these values in 01 mode. Can you share the waveform you are getting and PWM register dump?

For all other modes the values you are going to program can be decided based on two things:

1) Duty cycle

2) Position of pulse

For example in 01 mode:

Programming PWM_AH0 = -1000 ; and PWM_AH1 = -1500 ; will result in PWM pulse more towards first half of PWM period.

Similarly in mode 10 the whole pulse will be in left half of PWM period but depending on values programmed, position is decided.

Regards,

Nabeel

Hi Nabeel,

Thanks a lot. I got it.

Sorry for my wrong calculation, actually we get 25% dutycycle only with PWM_AH0 = -1500 and PWM_AH1 = -1000.

One more clarification Mr.Nabeel, For PULSEMODE=10 and 11, with PWM_AH0 = -1500 and PWM_AH1 = -1000 will we get 25% dutycycle again? And only difference is pulse positions will be in left half or right half for mode 10 and 11? Please correct me if I am wrong.

Is it for PULSEMODE = 10 and 11 maximum dutycycle is 50%?

Regards,

Kishore K

Message was edited by: Kishore K

Hi Kishore,

Glad to hear that you are getting the expected output.

Now for 10 and 11 mode things are little different.

For mode 10, assuming duty cycle is 0 the following conditions must be met:

PWM_xH0 > PWM_xH1

PWM_xH1 < PWM_TMx/2 for even PWM_TMx, or PWM_xH1 <= [PWM_TMx – 1]/2 for odd PWM_TMx

For mode 11, assuming duty cycle is 0 following conditions must be met:

PWM_xH0 < PWM_xH1

PWM_xH1 > -PWM_TMx/2 for even PWM_TMx, or PWM_xH1 <= -[PWM_TMx – 1]/2 for odd PWM_TMx

Yes, in mode 10 and 11, the maximum duty cycle is 50% only.

Regards,

Nabeel

Hi,

Thanks for detailing how you are obtaining the register values for different duty cycles.

But just to check back as per you calculation, for 25% duty the values come as -1250 for 00 mode which matches with what I suggested in my earlier post. So -1500 and -1000 should have resulted in 25% duty. I am not sure why you are getting only 10 % duty with these values in 01 mode. Can you share the waveform you are getting and PWM register dump?

For all other modes the values you are going to program can be decided based on two things:

1) Duty cycle

2) Position of pulse

For example in 01 mode:

Programming PWM_AH0 = -1000 ; and PWM_AH1 = -1500 ; will result in PWM pulse more towards first half of PWM period.

Similarly in mode 10 the whole pulse will be in left half of PWM period but depending on values programmed, position is decided.

Regards,

Nabeel