QN9080--- PWM

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

QN9080--- PWM

896 Views
danieltseng
Contributor V


I need to use a PWM to control the light, it need to able to adjust the frequency and duty arbitrarily.
I can't find an example in the SDK.
Can you provide an example for my reference, thanks

Labels (1)
  • QN

7 Replies

734 Views
danieltseng
Contributor V

Dear Sebastian:

Thank you for your best and quick reply.
I already know how to use PWM
Thank you

Daniel

734 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Daniel,

Please let me know if you have any further questions!

Best regards,

Sebastian

0 Kudos

734 Views
danieltseng
Contributor V

1. I also look at this example.
    What is the maximum frequency that can be reached in this example?  How to calculate frequency

2. Inverted waveform as shown below?

pastedImage_2.png

3. A custom function may need to be implemented on frequency. 

    How would it be easier to achieve this?

0 Kudos

734 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Daniel,

 

To change the ActiveLow/High configuration for a PWM signal, the level element of the sctimer_pwm_signal_param_t structure is the one responsible for establishing which value is considered "TRUE" for the generated PWM signal.

 

The maximum frequency achievable using the PWM SCTIMER functions is around 800kHz, any more than that, and the signal could get really deformed or not be generated as intended.

 

To be able to change the frequency when the SCTIMER is already running, the timer first has to be stopped using the SCTIMER_StopTimer function, then the new frequency can be established by using the SCTIMER_SetupPwm again, and then starting the timer again, with the SCTIMER_StartTimer function, for example:

SCTIMER_StopTimer(SCT0, kSCTIMER_Counter_L);
SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 30000U, sctimerClock, &eventNumberOutput4);
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_L);‍‍‍‍‍‍

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

734 Views
danieltseng
Contributor V

Dear Sebastian:

After reading SCTimer example, I have the following questions
1. Can I reverse the waveform?
2. Example default frequency of 24k , What is the maximum and minimum frequency range?
3. Example only adjust duty cycle, but do not see adjustment frequency function?

Daniel

0 Kudos

734 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

HI Daniel,

 

The SCTIMER functions provide a better interface to control the level of the generated PWM, allowing it to be either High or Low true.

 

The frequency of the PWM is configured with the SCTIMER_SetupPwm function, but to update the PWM frequency, a custom function may need to be implemented.

 

The maximum frequency is approximately half the configured Bus Clock frequency.

 

For more information, could you please take a look at the SCTIMER with PWM Duty Cycle change example? I can be found in the following path:

<…\SDK_2.2.1_QN908XCDK\boards\qn908xcdk\driver_examples\sctimer\pwm_with_dutycyle_change>

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

0 Kudos

734 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Daniel, I hope you're doing well!

 

The CTIMER and SCTIMER examples included in the SDK may help give you an idea on how to use a CTIMER/SCTIMER to generate a PWM of a certain frequency and duty cycle.

 

These can be found in the following paths:

<…\SDK_2.2.1_QN908XCDK\boards\qn908xcdk\driver_examples\sctimer">

<…\SDK_2.2.1_QN908XCDK\boards\qn908xcdk\driver_examples\ctimer">

 

The CTIMER_SetupPwm function initially configures the duty cycle and frequency, and the CTIMER_UpdatePwmDutycycle function can then be used to update to a different duty cycle.

 

Please let me know if you need any more information.

 

Best regards,

Sebastian

0 Kudos