Hello, I'm trying to use the FlexPWM peripheral of the MCXA156 SoC in a FRDM_MCXA156 devboard using Zephyr but I can't get it to fully work.
Whatever I try, the pulse and period seen in the associated output pins do not correspond with the values I am assigning it.
I have found a way to reproduce the issue using the blinky_pwm example. Using the reproduction steps below I only get a small pulse of less than 1ms in pin P3_6 (where channel 0 of flexpwm0_pwm0 is linked) whenever the PWM is reconfigured, but nothing in between. AFAIK the example should be setting a 50% duty cycle signal and that is not what I am seeing.
It is not a regression; I've tried the same thing on a semi-recent commit 0d46a93 and commit 9f6fdae (Where PWM was implemented for the FRDM_MCXA156 board) and the issue still happens.
Steps to reproduce:
- west init repro
- cd repro && west update
- Copy the following overlay file to samples/basic/blinky_pwm/boards/frdm_mcxa156.overlay:
#include <zephyr/dt-bindings/pwm/pwm.h>
/ {
pwmleds {
compatible = "pwm-leds";
pwm_led_0: pwm_led_0 {
pwms = <&flexpwm0_pwm0 0 PWM_MSEC(1) PWM_POLARITY_NORMAL>;
label = "PWM LED 0";
};
};
aliases {
pwm-led0 = &pwm_led_0;
pwm-0 = &flexpwm0_pwm0;
};
};Then:
- cd zephyr && west build -b frdm_mcxa156 samples/basic/blinky_pwm
- west flash
- See incorrect behavior when probing P3_6.
Logs don't show much:
[00:00:00.000,069] <dbg> pwm_mcux: pwm_mcux_init: Set prescaler 128, reload mode 2
*** Booting Zephyr OS build v4.2.0-2444-g0d46a934171a ***
PWM-based blinky
Calibrating for channel 0...
[00:00:00.017,179] <err> pwm_mcux: Too long period (750000), adjust pwm prescaler!
[00:00:00.025,412] <err> pwm_mcux: Too long period (375000), adjust pwm prescaler!
[00:00:00.033,645] <err> pwm_mcux: Too long period (187500), adjust pwm prescaler!
[00:00:00.041,879] <err> pwm_mcux: Too long period (93750), adjust pwm prescaler!
Done calibrating; maximum/minimum periods 62500000/7812500 nsec
Using period 62500000
Using period 31250000
Using period 15625000
Using period 7812500
Using period 15625000
Using period 31250000
...
Attached is the (compressed) ELF final binary I got doing these steps.
I hope this is just a mistake on my side. Appreciate any feedback on this matter!
Thanks in advance