adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
MIT License
3.96k stars 1.16k forks source link

Support PWM on TCx_0 pins #1766

Open ladyada opened 5 years ago

ladyada commented 5 years ago

currently used for the counter TOP, maybe we don't care as much about freq (just within the prescale divider ranges)

tannewt commented 5 years ago

We currently don't support the first capture compare channel right now because we use it to store the 16bit top value to get precise frequency.

raquo commented 3 months ago

Hello,

It looks like this issue is the reason why my Feather M4 express can not do PWM on pins A2, A4, and A5 (they're TC4[0], TC0[0], and TC1[0] respectively according to this chart, so it matches up).

Could you please update the Feather m4 express pinout documentation here to reflect this limitation? Currently it says:

A2 thru A5 - These are each analog input as well as digital I/O pins. These pins can also do PWM.

But, of those, only A3 can do PWM in CircuitPython.

I tested each pin where I expected PWM support with this code.py (on CircuitPython 8.2.10):

import board
import pwmio
pwmio.PWMOut(board.A2, duty_cycle=0, frequency=100)

A2, A4, and A5 pins were the only ones that didn't work (they threw "ValueError: All timers for this pin are in use" error).

dhalbert commented 3 months ago

Could you please update the Feather m4 express pinout documentation here to reflect this limitation? Currently it says:

Now noted in the Learn Guide. Thanks.