PWM Output configuration

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

PWM Output configuration

881 Views
larsmagne
Contributor II

I try to configure the eFlexPWM on a #i.MXRT166 to generate a simple PWM to control LCD-backlight via the K3 pin in my application. I use PWM3.Submodule 1 and have set up the standalone config tool (Ver15) to route A,1 to the K3 pin and set the pin to ouput.

Still I have no PWM signal on the K3 pin?

So then I checked that the PWM was running by setting up interrupts on VAL2 and VAL3 and then set the K3 pin manually via GPIO2.12 from the ISR. Then I have PWM on K3.

But I want to offload the MCU and route the signal directly from PWM3.SM1.A to K3.

When stepping through the generated init-code I saw that the OUTEN bit was not configured and initialized by the config tool, so I try to call add PWM_OutputEnable(PWM3_PERIPHERAL, kPWM_PwmA, kPWM_Module_1) manually.  But still no PWM.

Any idea what I have missed out?

Regards
Lars Magne 

0 Kudos
Reply
5 Replies

206 Views
larsmagne
Contributor II

I have played with the  "Output active level" to verify that the mapping between PWM3,A,1 and the K3 pin is ok. What I see is that the K3 pin switch to the opposite level than the Output active level setting. So the pin is set to the inactive level.

I have also verified that if I reconfigure the K3 pin to GPIO2-12 and set the pin on interrupt compare on VAL2 and clear the pin on VAL3 the the output follow the duty-cycle from the PWM.  

So now I just need the "magic setting" to make the K3 pin follow the PWM3,A,1 without help from an interrupt....

Anyone that knows how?   

0 Kudos
Reply

855 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

Thank you so much for your interest in our products and for using our community.

Assuming that you are taking about the RT1166, I recommend you to take as reference the SDK example evkmimxrt1160_pwm_cm7, which shows how to configure multiples PWM signals from different submodules of PWM1. You just need to try with the PWM3.

Hope it helps you.

Have a nice day!

0 Kudos
Reply

235 Views
larsmagne
Contributor II
I still have problems whit this.
 
Here is my test code:
 
#define PWM_SRC_CLK_FREQ       CLOCK_GetRootClockFreq(kCLOCK_Root_Bus)
#define DEMO_PWM_CLOCK_DEVIDER kPWM_Prescale_Divide_4
#define APP_DEFAULT_PWM_FREQUENCE (1000UL)

 

static void PWM_init(void)
{
    uint16_t deadTimeVal;
    pwm_signal_param_t pwmSignal[2];
    uint32_t pwmSourceClockInHz;
    uint32_t pwmFrequencyInHz = APP_DEFAULT_PWM_FREQUENCE;

 

    pwmSourceClockInHz = PWM_SRC_CLK_FREQ;

 

    /* Set deadtime count, we set this to about 650ns */
    deadTimeVal = ((uint64_t)pwmSourceClockInHz * 650) / 1000000000;

 

    pwmSignal[0].pwmChannel       = kPWM_PwmA;
    pwmSignal[0].level            = kPWM_HighTrue;
    pwmSignal[0].dutyCyclePercent = 50;
    pwmSignal[0].deadtimeValue    = deadTimeVal;
    pwmSignal[0].faultState       = kPWM_PwmFaultState0;
    pwmSignal[0].pwmchannelenable = true;

 

    PWM_SetupPwm(PWM3, kPWM_Module_1, pwmSignal, 1, kPWM_SignedCenterAligned, pwmFrequencyInHz, pwmSourceClockInHz);
}
 
I have set the pinmux on pin K4 and mapped it to PWM3 A,1 with Software Input On bit set.
But the K4 pin goes from "1" with pullup to steady "0" after the PWM_Init() function.
 
What have I missed out?  
 
0 Kudos
Reply

217 Views
larsmagne
Contributor II

just a small correction to a typo in my previous message: It is still K3 (GPIO_EMC_B2_02) and not K4 pin that I try to map to the output of sub-module 1 channel A in PWM 3.

I have tried both with peripheral configuration in MCUEXpresso config tool and with example code from NXP, but with the same result.

It must be a small but important detail I have missed out!?     

0 Kudos
Reply

195 Views
larsmagne
Contributor II
It seems like the output pin enter fault state after enabling the PWM.
PWM_GetStatusFlags(PWM3, ,PWM_Module_1)
returns 0x103f.
What can be the reason for this fault code?
0 Kudos
Reply