PWM on Beagleboard xM

I am trying to use the PWM pins on the expansion connector by following Mark Yoder’s code example at https://github.com/MarkAYoder/BeagleBoard-exercises for QNX 6.4.0. I have set the mux mode on the pins to 3 per the TRM. Using an oscilloscope, I see no PWM output. I do observe the timer counter register changing between the compare value and 0xffff ffff. Do I need to add pullup or pulldown? Or does anybody see a flaw in my attached code? I want to control a RC servo.

pwm.c (2.72 KB)

I am trying to use the PWM pins on the expansion connector by following Mark
Yoder's code example at https://github.com/MarkAYoder/BeagleBoard-exercises
for QNX 6.4.0. I have set the mux mode on the pins to 3 per the TRM. Using
an oscilloscope, I see no PWM output.

You can take a look at this file as an example:
https://github.com/veter-team/vehicle/blob/master/src/xenopwm.c
It uses Xenomai for precise timing and works more or less fine to
generate standard servo PWMs from user space [1] (kernel-space
implementation is under currently development). I think it should be
very easy to replace Xenomai calls with corresponding QNX API. Please
note, that in this example pin muxing is done via direct memory writes
using /dev/mem & co. (not from u-boot). All initialization
(pin-muxing) is done in initpwm() function. The actual pin toggling is
done in pwm_func().

For more details about the hardware we are using and project in
general, please see [2,3]

[1] http://veter-project.blogspot.co.uk/2011/09/real-time-enough-about-pwms-and-shaky.html
- article about our experience generating PWMs with GPIO from
user-space with Xenomai
[2] https://github.com/veter-team/veter/wiki - project wiki
[3] https://github.com/veter-team/veter/wiki/Hardware-design-en -
detailed information about hardware we are using

Looking at your project, my big question is why didn’t you use the PWM pins instead of bit-banging the GPIO’s? Then, you wouldn’t get the pulse width jitter that you are experiencing due to non-deterministic timing. Did you have the same problem that I am having (the PWM does not seem to work)?

Seams like the look was not close enough :wink: . In the source directory here:
https://github.com/veter-team/vehicle/tree/master/src
there are two files omap3530-pwm.{c,h} written by Thomas W. Most
<twm@freecog.net>. They are implementing higher level C interface to
control hardware PWMs. And here we are using it:
https://github.com/veter-team/vehicle/blob/master/src/MotorControlI_PWM.cpp#L154

In our project we are going to use more servo controllers, so we will
need more PWMs. But even this was not the main reason. The primary
goal was to learn Xenomai and see what could be achieved in the user
space, what should be implemented as a kernel module, etc. In fact I
am currently working on Xenomai (RTDM) based kernel module to generate
precise PWMs with GPIO. The next slightly more challenging step for us
would be to deal with interrupts generated by wheel encoders. And here
again we are going to use Xenomai-based solution, hence the need to
learn it. Example with PWMs is a simple yet useful case to learn the
new tool/library.

I notice in the code that I have looked at that the PWM pins are set to mode 2, although the TRM shows the PWM output as mode 3. Which is correct?

The following initialization works fine for me:

devmem2 0x48002176 h 0x0002
devmem2 0x48002178 h 0x0002

So I assume 2 is the right value.