No PWM output possible although MATT modes work

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

No PWM output possible although MATT modes work

1,888 Views
StMa
Contributor I

Hello,

I'm currently trying to figure out how to use the PWM Unit on a custom mx28 board. For now I just need a test software that generates a PWM signal with a base frequency of 1kHZ to 30kHz with different Duty cycles (for example 25/50/75%) on 4 different PWM Channels.

The Problem is that I don't see any output when I configure the PWM Unit to drive a PWM Pin. The only thing I see on the Pin is the 32kHz/24MHz oscillator when I configure MATT mode for the channels. Also I see a level change on the Pin when I change the Inactive/Active State bits in the PERIOD register of the channel, but no PWM is generated. It looks like the internal counter of the PWM is not running.

For testing I implemented the functionality in three different ways:
1) Using md/mw commands on the U-Boot shell to write the appropriate register
2) Adding appropriate code in U-Boot's board_init() function
3) Made a little C program using /dev/mem to access registers and do the magic this way

All three aproaches gave me the same result.

The steps I did to enable the PWM Channel 0 were (Pinmux is already correctly configured at this point):
1) Clear bit 29 in HW_CLKCTRL_XTAL to enable clock for the PWM
2) Clear bit 31 (SFTRST) and bit 30 (CLKGATE) in HW_PWM_CTRL to enable PWM unit operation
3) Clear bit 0 (PWM0_ENABLE) in HW_PWM_CTRL as suggested here: http://imxcommunity.org/group/imx28andimx28evk/forum/topics/can-t-get-pwm-to-work-on-a-imx283
4) Write 0x000004b0 to HW_PWM_ACTIVE0 and 0x000b095e to HW_PWM_PERIOD0 (shamelessy taken from above reference for testing, should result in 2399 Cycles of 24MHz Clock as period and roughly 50% duty cycle, no HSADC, no MATT and sane Active/Inactive states)
5) Set bit 0 in HW_PWM_CTRL to enable the channel.

I have also looked at some of the Linux implementations of the PWM, namely the PWM backlight driver from the Freescale kernel and to an implemenatation for a generic PWM driver for mxs in the official linux-next branch. I didn't see anything that gave me a hint why this doesn't work for me.
Also I tested this on two different boards to rule out a board related problem, both showed the same behavior.

Does anybody have a suggestion what I am missing to get the PWM running or any other pointers in the right direction to get this done ?

Thanks in advance,
Steve

Labels (1)
0 Kudos
Reply
2 Replies

1,340 Views
JorgeRama_rezRi
NXP Employee
NXP Employee

Hi, Steve,

Are you configuring the IOMUX registers before the PWM ones? If you want, for example, the PWM0 channel to actually be output at the PWM0 pin, you have to set the bits BANK3_PIN16 to 00. Please see section 9.4.9 PINCTRL Pin Mux Select Register 7 (HW_PINCTRL_MUXSEL7) of the reference manual for more info about these bits, and the whole chapter 9 for more info on the bits you have to configure for the rest of the channels you are using. As you'll see, none of the PWM channels is output at any pins by default, so you have to configure this first. Please note that you can output a specific channel in different pins, for example, PWM0 can also be output at pin AUART1_RX (see section 9.4.8), so be careful with the pins you are using.

Hope this helps!

Best regards.

Jorge.

1,340 Views
StMa
Contributor I

Hello Jorge,

Thanks for the reply and sorry for ressurecting this discussion after quite a long time but somehow I missed the notification email for that reply.

The Pinmux settings were set up correctly for all channels to have the PWM output functions on the appropriate pins for my board. I also verfied it twice in the source code and also could see the 32kHz Clock on any PWM pin when configuring the channel in MATT mode for this oscillator.

I haven't found a solution yet because my priorities shifted a bit and I don't have had time to evaluate this further.

Cheers,

Steve

0 Kudos
Reply