Quantcast

PWM Driver for Overo?

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PWM Driver for Overo?

Duane A. Damiano
I'd like to use my Overo Earth to control servos.  I searched this list
for postings about the PWM outputs on the Summit board and found some
from last November.  It seems that there was no PWM driver available at
that time.  Is that still the case?  Is there any driver or library that
I could get to use the Summit PWM outputs?  (I understand that the
voltage may not be right, but I can deal with that.)

Duane

------------------------------------------------------------------------------
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

bearclaw
Duane A. Damiano wrote:
> I'd like to use my Overo Earth to control servos.  I searched this list
> for postings about the PWM outputs on the Summit board and found some
> from last November.  It seems that there was no PWM driver available at
> that time.  Is that still the case?  Is there any driver or library that
> I could get to use the Summit PWM outputs?  (I understand that the
> voltage may not be right, but I can deal with that.)
>  
I'm no expert but I don't think those PWMs are suitable for servo
control. Looking at the omap spec,
PWM A and B are using a 7bit counter, and a 3MHz clock: far too fast to
generate ~= 1ms signals needed by servos.
PWM 0 and 1 are using a 32Khz clock, 7bit counter: a bit too slow, you
will get aproximately a 5 degres resolution
...and I'm not sure about the last remaining two

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

chawig
search for PPM on the Gumstix user wiki at
http://www.gumstix.net/wiki/index.php?title=Main_Page
Martial


Le samedi 18 avril 2009 21:51:38 bearclaw, vous avez écrit :

> Duane A. Damiano wrote:
> > I'd like to use my Overo Earth to control servos.  I searched this list
> > for postings about the PWM outputs on the Summit board and found some
> > from last November.  It seems that there was no PWM driver available at
> > that time.  Is that still the case?  Is there any driver or library that
> > I could get to use the Summit PWM outputs?  (I understand that the
> > voltage may not be right, but I can deal with that.)
>
> I'm no expert but I don't think those PWMs are suitable for servo
> control. Looking at the omap spec,
> PWM A and B are using a 7bit counter, and a 3MHz clock: far too fast to
> generate ~= 1ms signals needed by servos.
> PWM 0 and 1 are using a 32Khz clock, 7bit counter: a bit too slow, you
> will get aproximately a 5 degres resolution
> ...and I'm not sure about the last remaining two
>
> ---------------------------------------------------------------------------
>--- Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today.
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> gumstix-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

R. P. McMurphy
PWM A & B are for the LED control and are not brought to the pinout on
the Overo.

PWM 0 & 1 are the two listed in the pinout and operate on a slow 32kHz
clock. Controlled by the TPS chip.

The other 4 PWMs are from the OMAP chip and can operate over a wider
frequency range and are directly configurable from the CPU memory
space.

On 4/19/09, Martial Chateauvieux <[hidden email]> wrote:

> search for PPM on the Gumstix user wiki at
> http://www.gumstix.net/wiki/index.php?title=Main_Page
> Martial
>
>
> Le samedi 18 avril 2009 21:51:38 bearclaw, vous avez écrit :
>> Duane A. Damiano wrote:
>> > I'd like to use my Overo Earth to control servos.  I searched this list
>> > for postings about the PWM outputs on the Summit board and found some
>> > from last November.  It seems that there was no PWM driver available at
>> > that time.  Is that still the case?  Is there any driver or library that
>> > I could get to use the Summit PWM outputs?  (I understand that the
>> > voltage may not be right, but I can deal with that.)
>>
>> I'm no expert but I don't think those PWMs are suitable for servo
>> control. Looking at the omap spec,
>> PWM A and B are using a 7bit counter, and a 3MHz clock: far too fast to
>> generate ~= 1ms signals needed by servos.
>> PWM 0 and 1 are using a 32Khz clock, 7bit counter: a bit too slow, you
>> will get aproximately a 5 degres resolution
>> ...and I'm not sure about the last remaining two
>>
>> ---------------------------------------------------------------------------
>>--- Stay on top of everything new and different, both inside and
>> around Java (TM) technology - register by April 22, and save
>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
>> 300 plus technical and hands-on sessions. Register today.
>> Use priority code J9JMT32. http://p.sf.net/sfu/p
>> _______________________________________________
>> gumstix-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>
>
> ------------------------------------------------------------------------------
> Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today.
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> gumstix-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Frank Agius
In reply to this post by Duane A. Damiano
Duane A. Damiano wrote:

> I'd like to use my Overo Earth to control servos.  I searched this list
> for postings about the PWM outputs on the Summit board and found some
> from last November.  It seems that there was no PWM driver available at
> that time.  Is that still the case?  Is there any driver or library that
> I could get to use the Summit PWM outputs?  (I understand that the
> voltage may not be right, but I can deal with that.)
>
> Duane
>
> ------------------------------------------------------------------------------

The OMAP pwm's that are brought out onto the Summit board can be
configured and controlled from user space by writing directly to the
appropriate OMAP registers through /dev/mem .  The utility devmem2
allows for easy reading and writing through /dev/mem.  I built the
devmem2 package on my host (bitbake -b devmem2.bb), installed it on my
overo with opkg, then spent a couple of hours trying to make one of the
pwm pins on the summit wiggle.  Here is a sample script that should
enable a 2Khz pulse on PWM11 of the Summit:

#!/bin/bash
# for omap 35xx, setup pwm associated with general purpose timer 11 for
# a frequency of 2Khz, 50% duty cycle.  On the overo summit board 40 pin
# header, the output can be observed on pin 27 (GPIO146_PWM11)
devmem2 0x48088024 w 0x00000000 # set gtp11_TCLR, stop the timer
devmem2 0x48002178 h 0x00102    # set mux for gpt11_pwm_evt
devmem2 0x4808802c w 0xfffffff0 # set value for gpt11_TLDR, timer load
devmem2 0x48088038 w 0xfffffff8 # set value for gpt11_TMAR, timer match
devmem2 0x48088028 w 0xffffffff # set value for gpt11_TCRR, timercounter
devmem2 0x48088024 w 0x00001843 # set gtp11_TCLR, start the timer


frank


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

bearclaw
Frank Agius wrote:

> Duane A. Damiano wrote:
>  
>> I'd like to use my Overo Earth to control servos.  I searched this list
>> for postings about the PWM outputs on the Summit board and found some
>> from last November.  It seems that there was no PWM driver available at
>> that time.  Is that still the case?  Is there any driver or library that
>> I could get to use the Summit PWM outputs?  (I understand that the
>> voltage may not be right, but I can deal with that.)
>>
>> Duane
>>
>> ------------------------------------------------------------------------------
>>    
>
> The OMAP pwm's that are brought out onto the Summit board can be
> configured and controlled from user space by writing directly to the
> appropriate OMAP registers through /dev/mem .  The utility devmem2
> allows for easy reading and writing through /dev/mem.  I built the
> devmem2 package on my host (bitbake -b devmem2.bb), installed it on my
> overo with opkg, then spent a couple of hours trying to make one of the
> pwm pins on the summit wiggle.  Here is a sample script that should
> enable a 2Khz pulse on PWM11 of the Summit:
>
> #!/bin/bash
> # for omap 35xx, setup pwm associated with general purpose timer 11 for
> # a frequency of 2Khz, 50% duty cycle.  On the overo summit board 40 pin
> # header, the output can be observed on pin 27 (GPIO146_PWM11)
> devmem2 0x48088024 w 0x00000000 # set gtp11_TCLR, stop the timer
> devmem2 0x48002178 h 0x00102    # set mux for gpt11_pwm_evt
> devmem2 0x4808802c w 0xfffffff0 # set value for gpt11_TLDR, timer load
> devmem2 0x48088038 w 0xfffffff8 # set value for gpt11_TMAR, timer match
> devmem2 0x48088028 w 0xffffffff # set value for gpt11_TCRR, timercounter
> devmem2 0x48088024 w 0x00001843 # set gtp11_TCLR, start the timer
>
>
>  
Thanks to you and to McMurphy for those clarifications.


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Eruption
In reply to this post by Frank Agius
Frank Agius wrote
Here is a sample script that should
enable a 2Khz pulse on PWM11 of the Summit:

#!/bin/bash
# for omap 35xx, setup pwm associated with general purpose timer 11 for
# a frequency of 2Khz, 50% duty cycle.  On the overo summit board 40 pin
# header, the output can be observed on pin 27 (GPIO146_PWM11)
devmem2 0x48088024 w 0x00000000 # set gtp11_TCLR, stop the timer
devmem2 0x48002178 h 0x00102    # set mux for gpt11_pwm_evt
devmem2 0x4808802c w 0xfffffff0 # set value for gpt11_TLDR, timer load
devmem2 0x48088038 w 0xfffffff8 # set value for gpt11_TMAR, timer match
devmem2 0x48088028 w 0xffffffff # set value for gpt11_TCRR, timercounter
devmem2 0x48088024 w 0x00001843 # set gtp11_TCLR, start the timer
Where is the documentation that helped you figure out what registers are needed to configure your pwm?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Dave Hylands
Hi Eruption,

On Sat, Feb 13, 2010 at 9:00 AM, Eruption <[hidden email]> wrote:

>
>
> Frank Agius wrote:
>>
>> Here is a sample script that should
>> enable a 2Khz pulse on PWM11 of the Summit:
>>
>> #!/bin/bash
>> # for omap 35xx, setup pwm associated with general purpose timer 11 for
>> # a frequency of 2Khz, 50% duty cycle.  On the overo summit board 40 pin
>> # header, the output can be observed on pin 27 (GPIO146_PWM11)
>> devmem2 0x48088024 w 0x00000000 # set gtp11_TCLR, stop the timer
>> devmem2 0x48002178 h 0x00102    # set mux for gpt11_pwm_evt
>> devmem2 0x4808802c w 0xfffffff0 # set value for gpt11_TLDR, timer load
>> devmem2 0x48088038 w 0xfffffff8 # set value for gpt11_TMAR, timer match
>> devmem2 0x48088028 w 0xffffffff # set value for gpt11_TCRR, timercounter
>> devmem2 0x48088024 w 0x00001843 # set gtp11_TCLR, start the timer

That would be Chapter 16 of the Technical Reference Manual, titled
"Timers". Searching for PWM in the TRM also comes up with Chapter 16.

You can find the OMAP Technical reference manuals on the TI web site:
<http://focus.ti.com/docs/prod/folders/print/omap3530.html#technicaldocuments>
(along with lots of other useful documents)
The TRM weighs in just over 3500 pages, and is about 22 Mb.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Eruption
Dave Hylands wrote
>> #!/bin/bash
>> # for omap 35xx, setup pwm associated with general purpose timer 11 for
>> # a frequency of 2Khz, 50% duty cycle.  On the overo summit board 40 pin
>> # header, the output can be observed on pin 27 (GPIO146_PWM11)
>> devmem2 0x48088024 w 0x00000000 # set gtp11_TCLR, stop the timer
>> devmem2 0x48002178 h 0x00102    # set mux for gpt11_pwm_evt
>> devmem2 0x4808802c w 0xfffffff0 # set value for gpt11_TLDR, timer load
>> devmem2 0x48088038 w 0xfffffff8 # set value for gpt11_TMAR, timer match
>> devmem2 0x48088028 w 0xffffffff # set value for gpt11_TCRR, timercounter
>> devmem2 0x48088024 w 0x00001843 # set gtp11_TCLR, start the timer

That would be Chapter 16 of the Technical Reference Manual, titled
"Timers". Searching for PWM in the TRM also comes up with Chapter 16.

You can find the OMAP Technical reference manuals on the TI web site:
<http://focus.ti.com/docs/prod/folders/print/omap3530.html#technicaldocuments>
(along with lots of other useful documents)
The TRM weighs in just over 3500 pages, and is about 22 Mb.
Thanks, Dave.  I have another problem.  I tried running the script above, but I'm getting bus errors.  Here is the output of the script:

/dev/mem opened.
Memory mapped at address 0x40020000.
./pwm11.sh: line 5:  1846 Bus error               devmem2 0x48088024 w 0x00000000
/dev/mem opened.
Memory mapped at address 0x40020000.
Value at address 0x48002178 (0x40020178): 0x102
Written 0x102; readback 0x102
/dev/mem opened.
Memory mapped at address 0x40020000.
./pwm11.sh: line 7:  1848 Bus error               devmem2 0x4808802c w 0xfffffff0
/dev/mem opened.
Memory mapped at address 0x40020000.
./pwm11.sh: line 8:  1849 Bus error               devmem2 0x48088038 w 0xfffffff8
/dev/mem opened.
Memory mapped at address 0x40020000.
./pwm11.sh: line 9:  1850 Bus error               devmem2 0x48088028 w 0xffffffff
/dev/mem opened.
Memory mapped at address 0x40020000.
./pwm11.sh: line 10:  1851 Bus error               devmem2 0x48088024 w 0x00001843

I'm running 2.6.32 kernel on an overo.  Any ideas on how to track down the problem?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

ScottEllis
Disable CONFIG_OMAP_RESET_CLOCKS in your kernel config and rebuild it.

There is probably a more granular way to do this, but I haven't found it yet.

diff --git a/recipes/linux/linux-omap3-2.6.32/overo/defconfig b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
index 13a6b5a..744819c 100644
--- a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
+++ b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
@@ -204,7 +204,7 @@ CONFIG_ARCH_OMAP3=y
 #
 # CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
 # CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
-CONFIG_OMAP_RESET_CLOCKS=y
+# CONFIG_OMAP_RESET_CLOCKS is not set
 # CONFIG_OMAP_MUX is not set
 CONFIG_OMAP_MCBSP=y
 # CONFIG_OMAP_MBOX_FWK is not set
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Eruption

ScottEllis wrote
diff --git a/recipes/linux/linux-omap3-2.6.32/overo/defconfig b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
index 13a6b5a..744819c 100644
--- a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
+++ b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
@@ -204,7 +204,7 @@ CONFIG_ARCH_OMAP3=y
 #
 # CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
 # CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
-CONFIG_OMAP_RESET_CLOCKS=y
+# CONFIG_OMAP_RESET_CLOCKS is not set
 # CONFIG_OMAP_MUX is not set
 CONFIG_OMAP_MCBSP=y
 # CONFIG_OMAP_MBOX_FWK is not set
That did it!  Thanks Scott.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Steve Sakoman
In reply to this post by ScottEllis
On Sat, Feb 13, 2010 at 12:31 PM, ScottEllis
<[hidden email]> wrote:
>
> Disable CONFIG_OMAP_RESET_CLOCKS in your kernel config and rebuild it.

I've done this in the repository now.

CONFIG_OMAP_RESET_CLOCKS saves a bit of power by turning off clocks
that the kernel isn't using.  It probably is a better trade off to
leave them on, so that people can poke around with devmem2 using the
standard kernel build.

Folks that really care about every last milliamp can turn it back on.

Steve

> There is probably a more granular way to do this, but I haven't found it
> yet.
>
> diff --git a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> index 13a6b5a..744819c 100644
> --- a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> +++ b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> @@ -204,7 +204,7 @@ CONFIG_ARCH_OMAP3=y
>  #
>  # CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
>  # CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
> -CONFIG_OMAP_RESET_CLOCKS=y
> +# CONFIG_OMAP_RESET_CLOCKS is not set
>  # CONFIG_OMAP_MUX is not set
>  CONFIG_OMAP_MCBSP=y
>  # CONFIG_OMAP_MBOX_FWK is not set
>
> --
> View this message in context: http://old.nabble.com/PWM-Driver-for-Overo--tp22888603p27578502.html
> Sent from the Gumstix mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> gumstix-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

r1gga
I have discovered that the stock Overo Fire has PWM8 and PWM9 clocked at 13MHz, whereas PWM10 and PWM11 are clocked at 32kHz. Can these clocks be altered/assigned from the user space or is a kernel rebuild necessary?

Also, I am aware that PWM0 and PWM1 are connected to the TPS65950 chip and clocked at 32kHz. Can these PWM outputs be modified from the userspace similar to how PWM8-11 are controlled?

Many thanks,

Nicholas Robinson

For reference, Scott Ellis has posted a functional PWM Kernel Module and comprehensive Overo PWM guide, which I have found extremely useful:
http://github.com/scottellis/overo-pwm
http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=56&Itemid=63

sakoman wrote
On Sat, Feb 13, 2010 at 12:31 PM, ScottEllis
<scottellis.developer@gmail.com> wrote:
>
> Disable CONFIG_OMAP_RESET_CLOCKS in your kernel config and rebuild it.

I've done this in the repository now.

CONFIG_OMAP_RESET_CLOCKS saves a bit of power by turning off clocks
that the kernel isn't using.  It probably is a better trade off to
leave them on, so that people can poke around with devmem2 using the
standard kernel build.

Folks that really care about every last milliamp can turn it back on.

Steve

> There is probably a more granular way to do this, but I haven't found it
> yet.
>
> diff --git a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> index 13a6b5a..744819c 100644
> --- a/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> +++ b/recipes/linux/linux-omap3-2.6.32/overo/defconfig
> @@ -204,7 +204,7 @@ CONFIG_ARCH_OMAP3=y
>  #
>  # CONFIG_OMAP_DEBUG_POWERDOMAIN is not set
>  # CONFIG_OMAP_DEBUG_CLOCKDOMAIN is not set
> -CONFIG_OMAP_RESET_CLOCKS=y
> +# CONFIG_OMAP_RESET_CLOCKS is not set
>  # CONFIG_OMAP_MUX is not set
>  CONFIG_OMAP_MCBSP=y
>  # CONFIG_OMAP_MBOX_FWK is not set
>
> --
> View this message in context: http://old.nabble.com/PWM-Driver-for-Overo--tp22888603p27578502.html
> Sent from the Gumstix mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> gumstix-users mailing list
> gumstix-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Doug Gibbs
In case someone needs to talk to the TPS65950.
You can talk to it by using the ioctl command I2C_SLAVE_FORCE when setting the i2c address. If you do not use the FORCE, the set address ioctl will fail with the device in use error.

I was able to write a user space program to use the PWM0 and PWM1 outputs (the two that come out of the Overo connectors).

Be careful, the kernel driver is still active, if you write to the wrong thing, it will burn you.

The data sheet for the part is on the TI web site. In addition to setting the registers for the PWM, there are 2-3 setup registers that must be changed to enable the PWM.

Doug


This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

r1gga
Thanks for the lead Doug. I will have a look at the data sheet.

Do you happen to have a code snippet with the Setup procedure and frequency/pulse width calculation?

Thanks,
Nicholas

Doug Gibbs wrote
In case someone needs to talk to the TPS65950.
You can talk to it by using the ioctl command I2C_SLAVE_FORCE when setting
the i2c address. If you do not use the FORCE, the set address ioctl will
fail with the device in use error.

I was able to write a user space program to use the PWM0 and PWM1 outputs
(the two that come out of the Overo connectors).

Be careful, the kernel driver is still active, if you write to the wrong
thing, it will burn you.

The data sheet for the part is on the TI web site. In addition to setting
the registers for the PWM, there are 2-3 setup registers that must be
changed to enable the PWM.

Doug




This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

Doug Gibbs
This code would turn switch between two LED values. Based on input parameter we can adjust the brightness.

The PWM clock is 32K Hz, and the off/on settings are a bit wonky. Read the TI data manual for details.

#include <linux/i2c-dev.h>

#define TPS65950_I2C_GPIO_ADDR    0x49
#define TPS65950_I2C_GPBR1_ADDR  0x91
#define TPS65950_I2C_PMBR_ADDR  0x92

#define PWM0_1_OUTP_EN    0x34
#define PWM0_1_CLK_EN    0x0F

#define TPS65950_I2C_PWM_ADDR    0x4A
#define TPS65950_PWM0ON_REG        0xF8
#define TPS65950_PWM0OFF_REG    0xF9

#define TPS65950_PWM1ON_REG        0xFB
#define TPS65950_PWM1OFF_REG    0xFC

#define PWM_MIN    1
#define PWM_MAX    126


int
led_pwm_init(int i2c_fd){
    int addr;
    int value;
    /*
     * Setup the address on the I2C bus
     */
    addr = TPS65950_I2C_GPIO_ADDR;
    if (ioctl(i2c_fd, I2C_SLAVE_FORCE, addr) < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("IOCTL Failed in test, err := %s\n", strerror(errno));
        exit(1);
    }
    /*
     * Enable the PWM output, over ride the GPIO
     */
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR);
#ifdef I2C_PWM_TEST
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_PMBR_ADDR, value);
#endif
    value |= PWM0_1_OUTP_EN;
    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR, value) < 0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR);
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_PMBR_ADDR, value);
#endif
    /*
     * Now setup the enable and clock en
     */
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR);
#ifdef I2C_PWM_TEST
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_GPBR1_ADDR, value);
#endif
    value |= PWM0_1_CLK_EN;
    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR, value) < 0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR);
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_GPBR1_ADDR, value);
#endif

    addr = TPS65950_I2C_PWM_ADDR;
    if (ioctl(i2c_fd, I2C_SLAVE_FORCE, addr) < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("IOCTL Failed in test, err := %s\n", strerror(errno));
        exit(1);
    }

#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM0ON_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM0ON_REG, value);
#endif
   
    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0OFF_REG, 0x7F) < 0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM0OFF_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM0OFF_REG, value);
#endif

    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1OFF_REG, 0x7F) < 0){
        printf("Failed to write to i2c\n");
    }

#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM1OFF_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM1OFF_REG, value);
#endif
}

#ifdef I2C_PWM_TEST
int
led_pwm_test(int i2c_fd){
    int iter, addr;
    int value;

    /*
     * Loop through all possible values of the PWM. Pause in each loop,
     * this should take ~ 10 sec.
     */
    for(iter=0; iter < 128; iter++){
        printf("PWM = %d\n", iter);
        if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, iter) < 0){
            printf("Failed to write to i2c\n");
        }
        i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG,  (iter));   
       
        value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM1ON_REG);
        printf("Read from %02x = 0x%02x\n", TPS65950_PWM1ON_REG, value);

        usleep(30*1000000/128); /* 30 sec to msec/iterations */
    }
}
#endif

#define TRUE 1
#define FALSE 0

int
main(int argc, char **argv)
{
    int i2c_fd;
    int adapter_nr = 1; /* probably dynamically determined */
    char filename[20];
    int i, rd;
    int flip;
    int opt;
    int whiteval, grnval;
   
    whiteval = PWM_MAX;
    grnval = PWM_MAX;

    snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
    i2c_fd = open(filename, O_RDWR);
    if (i2c_fd < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("Failed to open i2c\n");
        exit(1);
      }

    led_pwm_init(i2c_fd);
#ifdef I2C_PWM_TEST
    led_pwm_test(i2c_fd);
#endif

    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, PWM_MIN);   
    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG, whiteval);   
    flip = FALSE;
    /*
     * Read from the GPIO attached to the switch inputs.
     */
   
    while (1)
    {
            switch(ev[i].code){
            case KEY_1:
            case KEY_2:
                if(flip){
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, PWM_MIN);   
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG, whiteval);   
                    flip = FALSE;
                }
                else{
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, grnval);   
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG, PWM_MIN);   
                    flip = TRUE;
                }
               
                break;
            default:
                break;
            }
        }
    }

    close(i2c_fd);
    return 0;
}

Doug


This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

r1gga
Thanks Doug, thats exactly what I was looking for.

Now I just need to find out how to change the clock speed for PWM8 through PWM11. I know this should be possible from the OMAP35x Technical Reference Manual:
Each timer can be clocked from either the system clock (12, 13, 16.8, 19.2, 26, or 38.4 MHz) or the
32-kHz clock. The selection of the clock source is made at the power, reset, clock management (PRCM)
module level. For more information, see Section 16.2.3.1, Clocking, Reset, and Power-Management
Scheme.
Table 16-2 and 16-3 (page 2541) give details on the selection bits involved. It seems that PRCM.CM_CLKSEL_PERx CLK_SEL_GPTx are the registers of interest. Section 4.7.7.12 PER Power Domain Clock Controls gives details on their function. I have located the following PRCM Kernel patch which gives some clues (http://linux.omap.com/pub/kernel/3430sdp/patches-applicable-over-linux-omap-2.6.git/Omap3PM-prcm-APIs.patch).

Does anyone know the exact procedure required to set PWM8 and PWM9 to be clocked at 13MHz?

Thanks,

Nicholas Robinson
Doug Gibbs wrote
This code would turn switch between two LED values. Based on input parameter
we can adjust the brightness.

The PWM clock is 32K Hz, and the off/on settings are a bit wonky. Read the
TI data manual for details.

#include <linux/i2c-dev.h>

#define TPS65950_I2C_GPIO_ADDR    0x49
#define TPS65950_I2C_GPBR1_ADDR  0x91
#define TPS65950_I2C_PMBR_ADDR  0x92

#define PWM0_1_OUTP_EN    0x34
#define PWM0_1_CLK_EN    0x0F

#define TPS65950_I2C_PWM_ADDR    0x4A
#define TPS65950_PWM0ON_REG        0xF8
#define TPS65950_PWM0OFF_REG    0xF9

#define TPS65950_PWM1ON_REG        0xFB
#define TPS65950_PWM1OFF_REG    0xFC

#define PWM_MIN    1
#define PWM_MAX    126


int
led_pwm_init(int i2c_fd){
    int addr;
    int value;
    /*
     * Setup the address on the I2C bus
     */
    addr = TPS65950_I2C_GPIO_ADDR;
    if (ioctl(i2c_fd, I2C_SLAVE_FORCE, addr) < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("IOCTL Failed in test, err := %s\n", strerror(errno));
        exit(1);
    }
    /*
     * Enable the PWM output, over ride the GPIO
     */
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR);
#ifdef I2C_PWM_TEST
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_PMBR_ADDR, value);
#endif
    value |= PWM0_1_OUTP_EN;
    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR, value) <
0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_PMBR_ADDR);
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_PMBR_ADDR, value);
#endif
    /*
     * Now setup the enable and clock en
     */
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR);
#ifdef I2C_PWM_TEST
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_GPBR1_ADDR, value);
#endif
    value |= PWM0_1_CLK_EN;
    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR, value) <
0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_I2C_GPBR1_ADDR);
    printf("Read from %02x = 0x%02x\n", TPS65950_I2C_GPBR1_ADDR, value);
#endif

    addr = TPS65950_I2C_PWM_ADDR;
    if (ioctl(i2c_fd, I2C_SLAVE_FORCE, addr) < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("IOCTL Failed in test, err := %s\n", strerror(errno));
        exit(1);
    }

#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM0ON_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM0ON_REG, value);
#endif

    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0OFF_REG, 0x7F) < 0){
        printf("Failed to write to i2c\n");
    }
#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM0OFF_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM0OFF_REG, value);
#endif

    if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1OFF_REG, 0x7F) < 0){
        printf("Failed to write to i2c\n");
    }

#ifdef I2C_PWM_TEST
    value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM1OFF_REG);
    printf("Read from %02x = 0x%02x\n", TPS65950_PWM1OFF_REG, value);
#endif
}

#ifdef I2C_PWM_TEST
int
led_pwm_test(int i2c_fd){
    int iter, addr;
    int value;

    /*
     * Loop through all possible values of the PWM. Pause in each loop,
     * this should take ~ 10 sec.
     */
    for(iter=0; iter < 128; iter++){
        printf("PWM = %d\n", iter);
        if(i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, iter) <
0){
            printf("Failed to write to i2c\n");
        }
        i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG,  (iter));

        value = i2c_smbus_read_byte_data(i2c_fd, TPS65950_PWM1ON_REG);
        printf("Read from %02x = 0x%02x\n", TPS65950_PWM1ON_REG, value);

        usleep(30*1000000/128); /* 30 sec to msec/iterations */
    }
}
#endif

#define TRUE 1
#define FALSE 0

int
main(int argc, char **argv)
{
    int i2c_fd;
    int adapter_nr = 1; /* probably dynamically determined */
    char filename[20];
    int i, rd;
    int flip;
    int opt;
    int whiteval, grnval;

    whiteval = PWM_MAX;
    grnval = PWM_MAX;

    snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
    i2c_fd = open(filename, O_RDWR);
    if (i2c_fd < 0) {
        /* ERROR HANDLING; you can check errno to see what went wrong */
        printf("Failed to open i2c\n");
        exit(1);
      }

    led_pwm_init(i2c_fd);
#ifdef I2C_PWM_TEST
    led_pwm_test(i2c_fd);
#endif

    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG, PWM_MIN);
    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG, whiteval);
    flip = FALSE;
    /*
     * Read from the GPIO attached to the switch inputs.
     */

    while (1)
    {
            switch(ev[i].code){
            case KEY_1:
            case KEY_2:
                if(flip){
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG,
PWM_MIN);
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG,
whiteval);
                    flip = FALSE;
                }
                else{
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM0ON_REG,
grnval);
                    i2c_smbus_write_byte_data(i2c_fd, TPS65950_PWM1ON_REG,
PWM_MIN);
                    flip = TRUE;
                }

                break;
            default:
                break;
            }
        }
    }

    close(i2c_fd);
    return 0;
}

Doug




This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

ScottEllis
I think you meant set PWM10 and PWM11 to 13MHz.

Using the register description in section 4.14.1.5.12 CM_CLKSEL_CORE
Table 4-138.

# pwm10 off
root@overo:~# devmem2 0x48086024 w 0

# make sure the mux is correct for PWM
root@overo:~# devmem2 0x48002176 h 0x0002

# read CM_CLKSEL_CORE
root@overo:~# devmem2 0x48004A40 w
Value at address 0x48004A40 (0x40020a40): 0x30A

# 0x30A => CM_CLKSEL_CORE.CLKSEL_GPT10 = CM_32K_CLK

# set CLKSEL_GPT10 to CM_SYS_CLK, the 13MHz clock
root@overo:~# devmem2 0x48004A40 w 0x034a
 
# cut the freq down by 1024 (my scope isn't fast enough to do 13MHz)
root@overo:~# devmem2 0x4808602c w 0xfffffc00

# set a 50% duty cycle
root@overo:~# devmem2 0x48086038 w 0xfffffdff
 
# init the timer counter
root@overo:~# devmem2 0x48086028 w 0xfffffc00

# run it
root@overo:~# devmem2 0x48086024 w 0x1843

I get a frequency of 12.7KHz which multiplied by 1024 = 13MHz

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PWM Driver for Overo?

YatishDravid
In reply to this post by Duane A. Damiano
Hi Duane

Did you manage to control servos?

I am trying to do the same with a overo earth and summit. I am able to get the PWM working at any frequency withing the specified range.
The problem I am facing is not listed any where here.

The problem is how to give accurately X no. of pulses at a set frequency with a 50% Duty cycle.

For eg. how can i give 1200 pulses at 30Khz at 50% duty cycle, and stop there?
Is there a counter functionality in the PWM where we can set the numbers of pulses it should output.

-Yatish

Duane A. Damiano wrote
I'd like to use my Overo Earth to control servos.  I searched this list
for postings about the PWM outputs on the Summit board and found some
from last November.  It seems that there was no PWM driver available at
that time.  Is that still the case?  Is there any driver or library that
I could get to use the Summit PWM outputs?  (I understand that the
voltage may not be right, but I can deal with that.)

Duane

------------------------------------------------------------------------------
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Loading...