IMX8 PWM source clock frequency

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

IMX8 PWM source clock frequency

1,183 Views
eoin_oconnell
Contributor I

I am using the Toradex Verdin IMX8MP module and I need to generate a clock frequency of  1-3MHz from the PWM output pin.

I can currently get it to aroud 500kHz but after that the PWM peripheral does not behave at all even though the correct numbers are being written to the period and duty cycle registers.

 

Why am I observing this behaviour? For example when I try to put duty cycle to 10 and period to 20 in the registers I suddenly get a period of around 20ms and not 1-2us.

 

My PWM has a source clock of 24MHz, how can I change the PWM clock frequency, the datasheet shows it supports a number of different input sources, but where can I edit this source in the device tree? 

 

My dt base for the pwm looks like this:

 

			pwm2: pwm@30670000 {
				compatible = "fsl,imx8mp-pwm", "fsl,imx27-pwm";
				reg = <0x30670000 0x10000>;
				interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
				clocks = <&clk IMX8MP_CLK_PWM2_ROOT>,
					 <&clk IMX8MP_CLK_PWM2_ROOT>;
				clock-names = "ipg", "per";
				#pwm-cells = <2>;
				status = "disabled";
			};

 

The pwm get enabled higher in the DT, how can I select the other sources it supports?

 

According to the reference manual page 242 i can select these with a max of 66MHz

 

000 - 24M_REF_CLK
010 - SYSTEM_PLL1_DIV5
110 - SYSTEM_PLL1_DIV10
011 - SYSTEM_PLL1_DIV20
001 - SYSTEM_PLL2_DIV10
100 - SYSTEM_PLL3_CLK
111 - VIDEO_PLL_CLK
101 - EXT_CLK_1

 

0 Kudos
2 Replies

942 Views
embeddeddan
Contributor I

@eoin_oconnell, I am running into the same issue you were. Did you find a solution.

 

Any help is greatly appreciated. 

 

Dan

0 Kudos

1,101 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @eoin_oconnell,

The behavior you mentioned is odd. But from the device tree node, it looks like the node is defined properly and the PWM should work fine.

There might be a few possible reasons for this kind of behavior. To debug more, can you provide me with the following details?

  • What values are you setting in the period and duty_cycle values?
  • How are you measuring the frequency at the PWM_OUT pin?

 

Regards,
Dhruvit.

0 Kudos