How to change PWM frequency

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

How to change PWM frequency

Jump to solution
3,101 Views
Hiroki
NXP Employee
NXP Employee

Hi,

I'd like to know hot to generate the function to change the PWM frequency.

PE can generate the setRatio(). This setRatio can change the duty of PWM.

I'd like to change the PWM frequency. However, I cannot find the method to change the PWM frequency.

Could you show me which method can change it?

Best Regards,

Hiroki

Tags (2)
0 Kudos
Reply
1 Solution
2,429 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Hiroki,

I just checked, you need set PPG period as "interval" . the default one is "fix" which can not work with Setperiod related method.

see attached video for where to set it.

can this help you


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
6 Replies
2,428 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Hiroki.

if you need change PWM period, we need to use PPG(programmable Pulse generation) component instead. there is SetPeriod related method for it.

can this help?


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,428 Views
Hiroki
NXP Employee
NXP Employee

Hi Zhang,

Would you mean PPG_LDD? I selected PPG_LDD but SetPeriod method was selected "don't generate code" and I couldn't change that configuration.

How should I do to select "generate code" of SetPeriod?

Best Regards,

Hiroki

0 Kudos
Reply
2,430 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Hiroki,

I just checked, you need set PPG period as "interval" . the default one is "fix" which can not work with Setperiod related method.

see attached video for where to set it.

can this help you


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
2,428 Views
vijenad
Contributor III

Before going for main project, we want to understand the components, trying to generate PWM by using PPG1:PPG (not looking into  type of waveform generated and other points),  I am flashing the code on TRJ-KEA128 board, but led on-boar connected at output is not blinking.

(Same configuration - I tried with Running Settings type- Fixed, it works)

And also can you explain more on Init Value, Low Limit, High Limit and how they are related to the type of output we want to generate?

for(;;)

  {

  PPG1_Enable();

            PPG1_SetPeriodSec(1);

PPG1_SetDutyMS(500);

PPG1_SetRatio8(120);

}

2,428 Views
vijenad
Contributor III

Code to generate square wave form with varying frequency in run time.  Duty cycle is constant - 50%. Frequency is varied in run time

for(;;)

  {

   PPG1_SetRatio16(PPGPtr,32767);

  PPG1_SetPeriodMS(PPGPtr,1);

    for(i=0;i<65535;i++)

    {

    __asm("nop");

    }

    PPG1_SetPeriodMS(PPGPtr,10);

    for(i=0;i<65535;i++)

        {

    __asm("nop");

        }

     }

from interval - the table has three rows that contain the Initial value, low limit and high limit of the interval. Allows to change a timing freely within a selected interval (for low limit to high limit), while all values of the interval are selected with specified precision. Prescaler value is fixed in this mode, timing is set only using compare/reload registers value. It means that it is possible to reach all values within the interval by using the same prescaler.

2,429 Views
Hiroki
NXP Employee
NXP Employee

Hi Zhang,

Thank you very much for your help.

It can help me to understand.

Best Regards,

Hiroki

0 Kudos
Reply