pyboard PWM capable pins...

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Delebel
Posts: 48
Joined: Thu May 25, 2017 2:21 pm
Contact:

pyboard PWM capable pins...

Post by Delebel » Wed Apr 22, 2020 7:40 pm

I've done quite a bit of searching and it remains unclear which pins from a hardware point of view are capable of doing PWM on the pyboard. There is a section in the micropython tutorial 4.2 called The special leds... That mentions that only led 3 & 4 can be used with PWM or used with the intensity() method. So my question is there a list mentioned (anywhere in the documentation) of the pins on the pyboard that have that capability. I'm doing some custom wiring of an LCD for which I hope to drive the backlight on PWM. (obviously with buffering given the current load of the backlight led). Bottom line which IOs have that "Special led feature" that I could not find out short of spending a lot of time analysis the datasheet on the STM32F405 family. I know that IOs can be mapped to different pins on several of these advanced MCUs but I just need a quick and dirty pin list for my hardware IO selection.Basically I'd rather find out sooner than later if my IO pin selection will remain relevant once I start coding. I have other PWM needs for a buzzer and possibly 4 stepper outputs.

Thanks...Denis

User avatar
Kip
Posts: 31
Joined: Sat Dec 26, 2015 7:23 am

Re: pyboard PWM capable pins...

Post by Kip » Wed Apr 22, 2020 8:22 pm

Your pin selection will be based on what timer you use. See this image for the pins and their corresponding timers http://micropython.org/resources/pybv11-pinout.jpg

You use a channel to connect your pin(s) to your timer. For example:

```python
timer = pyb.Timer(2, freq=1000)
ch2 = timer.channel(2, pyb.Timer.PWM, pin=pyb.Pin.board.X2, pulse_width=8000) ch3 = timer.channel(3, pyb.Timer.PWM, pin=pyb.Pin.board.X3, pulse_width=16000)
```

Sent from my Pixel 2 XL using Tapatalk


User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: pyboard PWM capable pins...

Post by dhylands » Wed Apr 22, 2020 9:38 pm

Basically, any pin that's labelled starting with TIM can be used for PWM.

All of the channels on the same time will have to run with the same frequency, but each channel can have it's own duty cycle.

And if the same timer/channel appears in multiple places they'll the same (or negative version) of the PWM.

For example, TIM8_CH1 appears on Y1. TIM8_CH1N appears on X6 and X8. The TIM8_CH1N is an inverted version of TIM8_CH1.

Delebel
Posts: 48
Joined: Thu May 25, 2017 2:21 pm
Contact:

Re: pyboard PWM capable pins...

Post by Delebel » Tue Apr 28, 2020 8:24 pm

Thanks for the response. Yes I've sort of figured that out after finding a pybv3 (my cheap china board is v3) pinout listing from a pins.af() procedure (script) someone ran on their board. There are timers assigned to multiple pins so it was easy to pick one. For now I will setup my hardware IOs with jumpers selection so I can change pins fairly easily until I'm sure its going to work on coding. Thanks again

Post Reply