Generate PWM from M4 Apalis iMX8

We are struggling to overcome an apparent gap in the NXP SDK w.r.t controlling PWM from the M4 cores.

Spefically, the suggested SDK from both toradex and NXM (SDK_2.5.2_MIMX8QM6xxxFF) has no fsl_pwm driver implementation. This driver does exist for the same device (MIMX8QM6) but targeted to a different part (the 8Quad) in this SDK: SDK_2.7.0_MIMX8MQ7xxxJZ, but is conspicuously absent for the 8QuadMax’s SDK.

We are seek guidance to enable this (supposedly standard?) functionality from on this part. Specifically

(1) Porting the fsl_pwm driver for use with the 2.5.2 SDK (clock configurations could get hairy)
(2) Porting the 2.7.2 SDK for use on the 8QuadMax, or
(3) SDK-free implementation that generats PWM from an M4 core using (e.g.) LSIO.PWM1.OUT

Thanks in advance for any advice or suggestions.

Greetings @Gwen!

Note that the MIMX8MQ7xxxJZ device is the NXP i.MX 8M, not the i.MX 8. This gets confusing with all the part numbers.

Now checking the avaliable SDK for the i.MX 8 (SDK_2.5.2_MIMX8QM6xxxFF), I noticed that PWM is actually there - it is implemented using the TPM (Timer PWM Module) hardware. Some examples are shipped with the SDK, please check on boards/mekmimx8qm/driver_examples/tpm.

Thanks for the answer, Gustavo, although I don’t think it’s quite what we’re looking for.

(1) We’re aware the SDK’s are for different parts; we referenced MIMX8MQ7xxxJZ as an example of the functionality we were hoping to find or create for our part, which uses MIMX8QM6xxxFF.

(2) One CANNOT use the TPM to generate PWM on GPT1_COMPARE, which can be configured as LSIO.PWM2.OUT. We would like to generate a PWM signal on this specific pin, so using the TPM is not an option.

Hence, looking for guidance or reference implementations on actually generating PWM on LSIO.PWM2.OUT, without using the TPM. Any ideas on that?


Thanks for the info. I checked the SDK sources you mentioned for the i.MX 8M and even for the i.MX 8M Mini and they all have the fsl_pwm implementation just like you said.

As far as the NXP documentation goes, it seems that their intended way to use PWM on the M4 cores would be via the TPM or the FTM (FlexTimer Module). These are tightly coupled to the M4 cores.

Also according with their documentation, since the “regular” PWM module is also present, I don’t see why it shouldn’t work, but as you said, this would require a port.

We’re only working with what NXP provides SDK-wise, so I think the easiest way to go - besides using TPM or FTM - would be to port the fsl_pwm driver. Although the clock configuration might differ, it seems easier than porting the whole SDK 2.7.0 or coming up with a whole new implementation.

We ended up porting pwm_fsl drivers from the other SDK. The attached are working for text


Thanks a lot for the feedback and for the sources!