IMX8 M4 PWM module driver

Hello everyone,

I’m running using an Apalis IMX8QM mounted on a V1.2 Ixora board and would like to try and generate some different PWM outputs, I have tried the following:

using the TPM module to generate a PWM signal, which is mostly working but doesn’t work when I set the frequency at 10Hz in this function TPM_SetupPwm(BOARD_TPM, &tpmParam2, 1U, kTPM_EdgeAlignedPwm, 200U, TPM_SOURCE_CLOCK); // change 200U to 10U and it doesn't work
Second problem is that if I try to generate two PWM signals on both the TPM channels, the channels are driven with the highest frequency, so for example:

TPM_SetupPwm(BOARD_TPM, &tpmParam, 1U, kTPM_EdgeAlignedPwm, 100U, TPM_SOURCE_CLOCK);
TPM_SetupPwm(BOARD_TPM, &tpmParam2, 1U, kTPM_EdgeAlignedPwm, 200U, TPM_SOURCE_CLOCK);

// both set at duty cycle 10%

will output the following signal:

where the frequency of both signals are now at 200Hz, and 100Hz signal duty cycle is doubled. you can find the source code here:
tpm_timer.c (5.3 KB)
I would need both signals to have their own periods/frequencies. I think the 10Hz signal is not working due to some clock issue, I’m discovering the imx8 so maybe I am configuring things wrong.

Anyways, the main question here is that I wanted to test the PWM module instead of the TPM and see what happens, but there is no pwm driver in the SDK 2.9 from NXP, I have seen this two-year old Generate PWM from M4 Apalis iMX8 thread but the files that the user uploaded only contains the PWM_Setup function and non of the rest in this API, and I thought to ask as maybe there are some new driver that I can’t find

Using the PWM module will be my main choice even if it has the same implementation of the TPM modules as the Ixora board has 4xPWM channels/pins and only 2xTPM channels/pins

I’m not sure if this question lies within the scope of Toradex support, I also posted on the NXP forums but they are very slow to respond, let me know if this is out of scope and close the thread.

Thank you

Hi @AhmedMobarez,

Sorry for the delay, I’m already taking a look into this and I’ll get back to you as soon as I have something to share.

Good to know you have also opened a ticket in the NXP community, then we can see what the engineers there will say about the PWM.

Best Regards,

1 Like

Hey Hiago @hfranco.tx
Apparently NXP are not currently supporting this

Hi @AhmedMobarez,

Thanks for sharing this information!

As you mentioned, the only information that I found about the TPM was in the NXP API as well.

Were you able to solve your problem or are you facing the same issues with the PWM?

Best regards,

Hello @hfranco.tx ,

The first problem of running the signal at 10Hz is solved, wasn’t really a problem I just missed an equation while reading fsl_tpm.c and once I saw it I managed to get it working, but the other one of generating two independent signals not yet, I also haven’t worked on it much since then, but I am getting back to it this week and will let you know.