Skip to content

Enable DMTimer PWM pins on BBB and PB #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 31, 2020

Conversation

daschachter
Copy link
Contributor

Scope of Change
As referenced in #229, there are additional PWM pins available for use on the BeagleBoard. These pins take advantage of the DMTimer to create PWM signals. The current version of Adafruit_BBIO.PWM does not have support for these pins. This PR adds support for these pins without change the structure of Adafruit_BBIO.PWM from the user's perspective (see the "Tests/Examples" section of this PR).

To add support for these pins, a different PWM path is used when accessing the DMTimer pins. To elaborate, when a DMTimer pin is accessed, its properties can be changed in /sys/devices/platform/dmtimer-pwm-*/pwm/pwmchip*/pwm0/ (after exporting the pin within the pwmchip directory). This is different from the ocp path used for the standard PWM pins.

Fortunately, because of the structure of this library -- especially the pwm_exp struct (which stores the PWM config files) -- the majority of the changes are localized within the pwm_setup function of c_pwm.c. Minor modifications were also made to the tables found in common.c.

Limitations
The current changes are meant to support the PocketBeagle and BeagleBone Black. The code has only been tested on a PocketBeagle (see the "Tests/Examples" section). See #229 for a list of kernels that support PWM output from the DMTimer pins. In order to use these pins, the proper device tree overlays must be loaded (these for PocketBeagle and these for BeagleBone Black)

Tests/Examples
This feature has only been tested on a PocketBeagle (due to the availability of resources), but should also work on the BeagleBone Black. To test the functionality, I loaded PB-PWM-TIMER-P1.20.dtbo, connected an LED to P1_20, and ran the following in my Python shell:

import Adafruit_BBIO.PWM as PWM  
PWM.start("P1_20", 50) # LED turns on
PWM.set_duty_cycle(10) # LED dims
PWM.stop("P1_20") # LED turns off

I repeated this for the other four DMTimer pins on the PocketBeagle.

This example illustrates how the library itself has not changed from the user's perspective (this is the same code that would be used for any PWM pin). I've run this test on the currently recommended Buster IoT image ("AM3358 Debian 10.3 2020-04-06 4GB SD IoT"), as well as the 2020-07-13, Buster IoT testing image "bone-debian-10.4-iot-armhf-2020-07-13-4gb.img.xz".

@daschachter
Copy link
Contributor Author

@flosincapite

@daschachter daschachter marked this pull request as ready for review July 24, 2020 14:48
@pdp7
Copy link
Collaborator

pdp7 commented Jul 31, 2020

@daschachter thanks for the PR. It looks nicely prepared. I should be able to review and test out today.

@pdp7 pdp7 self-requested a review July 31, 2020 21:27
@pdp7 pdp7 closed this Jul 31, 2020
@pdp7 pdp7 reopened this Jul 31, 2020
@pdp7 pdp7 closed this Jul 31, 2020
@pdp7
Copy link
Collaborator

pdp7 commented Jul 31, 2020

ugh! sorry my browser is misbehaving.

@pdp7 pdp7 reopened this Jul 31, 2020
@pdp7 pdp7 merged commit 0c7cdaf into adafruit:master Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy