Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Teensy 4.1 PWM / Pulseio issue
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Teensy 4.1 PWM / Pulseio issue

by mstopps on Wed Jul 22, 2020 9:24 am

I'm having issues with using pulseio with the Teensy 4.1. For example, D13 (LED) to my knowledge is a PWM capable pin, however on use it errors 'Invalid pin'. Switching to line board.D1 does not invoke error, but no PWM signal is output as expected. I'd appreciate any suggestions, thanks.

Adafruit CircuitPython 6.0.0-alpha.1 on 2020-07-03; Teensy 4.1 with IMXRT1062DVJ6A
>>> import board
>>> import pulseio
>>> led = pulseio.PWMOut(board.D13)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid pin

Code: Select all | TOGGLE FULL SIZE
import time
import board
import pulseio

led_pwm = pulseio.PWMOut(board.D1, frequency=5000, duty_cycle=0)
 
while True:
    for i in range(100):
        # PWM LED up and down
        if i < 50:
            led_pwm.duty_cycle = int(i * 2 * 65535 / 100)  # Up
        else:
            led_pwm.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100)  # Down
        time.sleep(0.01)

mstopps
 
Posts: 1
Joined: Wed Jul 22, 2020 9:09 am

Re: Teensy 4.1 PWM / Pulseio issue

by tannewt on Wed Jul 22, 2020 4:43 pm

Our PWM support on the iMX RT is incomplete so it's likely a bug. The issue to track it is here: https://github.com/adafruit/circuitpython/issues/2489

The PWM pin list is here: https://github.com/adafruit/circuitpyth ... iph.c#L204

The implementation is here: https://github.com/adafruit/circuitpyth ... o/PWMOut.c

Let me know if you'd like to help finish it! Adafruit-sponsored development has shifted to ESP32S2 at the moment.

tannewt
 
Posts: 1716
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.