init Uart pins as PWM out

100 views Asked by At

Using circuitPython on Feather m0 basic, I'm unable to use Board pins 10 and 11 as PWM outs at the same time.

They both work with pwmio.PWMOut() separately, but If I try to initialize both of them at the same time the program crashes.

I found that these are the UART pins. Is there a way to configure these pins to both be PWM outs at the same time?

1

There are 1 answers

0
KevinJWalters On

I'm not sure exactly which pins you are referring to but this looks fine on CircuitPython 6.0.1 on an Adafruit Feather M0 Bluefruit, an example from REPL:

Adafruit CircuitPython 6.0.1 on 2020-12-28; Adafruit Feather M0 Adalogger with samd21g18
>>>
>>> import boardpulseio
>>> pwm_d11 = pulseio.PWMOut(board.D11)
>>> pwm_d12 = pulseio.PWMOut(board.D12)
>>> pwm_d11.duty_cycle = 10000
>>> pwm_d11.duty_cycle = 12000
>>> pwm_d12.duty_cycle = 40000
>>> pwm_d12.duty_cycle = 38000
>>> pwm_tx = pulseio.PWMOut(board.TX)
>>> pwm_rx = pulseio.PWMOut(board.RX)
>>> pwm_tx.duty_cycle = 12345
>>> pwm_rx.duty_cycle = 54321

How does yours differ from that? What's the error message?

Are you using variable_frequency or specifying different frequencies? That causes more hardware counters to be used under the covers.