AnsweredAssumed Answered

No PWM output possible although MATT modes work

Question asked by StMa on Jul 26, 2012
Latest reply on Oct 4, 2012 by StMa

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

Outcomes