- jamesh
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 35174
- Joined: Sat Jul 30, 2011 7:41 pm
Re: Possible hardware or MicroPython bug?
You must do a lot of lamenting, because every time someone buys a Pi to run something from `apt`, we make a (small) profit.hippy wrote: ↑Mon Sep 22, 2025 2:11 pm1) Because this is the MicroPython sub-forum.jamesh wrote: ↑Mon Sep 22, 2025 1:36 pmWhy single out Micropython for special treatment when there are so many other projects?hippy wrote: ↑Mon Sep 22, 2025 1:28 pmI still consider it lamentable that, even though Raspberry Pi profit from having MicroPython available for RP2 devices and Pico-range boards, they still do not appear to be a sponsor of the MicroPython project, helping to improve MicroPython and its documentation for the users of it.
2) Because this thread relates to MicroPython documentation issues which might well be resolved through more sponsorship.
I think it's lamentable when any company profits from the work of others but doesn't reward those who help generate those profits. To me it's no better than profiting from the work of unpaid interns - which Raspberry Pi also seems to find abhorrent.
If you can provide a list of projects Raspberry Pi profits from but doesn't sponsor or contribute to in return I will be happy to pass judgement on those. It's probably better to start a separate thread if there are so many.
1. The question of sponsorship is broader than just Micropython
2. Would they?
Software guy, working in the applications team.
Re: Possible hardware or MicroPython bug?
Indeed but this is the sub-forum for MicroPython so lamenting lack of Raspberry Pi sponsorship for MicroPython is pertinent and valid here IMO.
Whatever the wider issues of sponsorship are I don't believe it invalidates my lament that Raspberry Pi doesn't sponsor the MicroPython project.
I believe so. The issue of RP2 specific documentation being incomplete or lacking might however be better addressed by Raspberry Pi contributing their expertise in those areas. That would at least serve RP2 and Pico-range users if no one else. It currently seems Raspberry Pi does neither.
Re: Possible hardware or MicroPython bug?
This is a topic on a (possible) bug which you hijacked to start 'lamenting'.
Something you seem to enjoy...
Re: Possible hardware or MicroPython bug?
I don't agree with either but you are entitled to your opinion.
My lament was in response to a poster noting that MicroPython "do not have the time ..." and that's very true. They are a small and poorly funded team running a rather huge project. That could IMO be improved upon if they received more sponsorship.
Re: Possible hardware or MicroPython bug?
MicroPython is part of a business entity.
But back to the problem:
I think it's a concept issue how the PWM slices (modules) and channels are tied to pins in MicroPython.
The second constructor (user_led) should throw an error as the same hardware (PWM slice) and the same channel is already used (conflict).
If want to use multiple pins, the user should do it through GPIO function select.
But back to the problem:
Code: Select all
pico_led = PWM(Pin(25), freq=1000) # Pico's on-board LED (GPIO25)
user_led = PWM(Pin(9), freq=1000) # standalone LED wired to GPIO9The second constructor (user_led) should throw an error as the same hardware (PWM slice) and the same channel is already used (conflict).
If want to use multiple pins, the user should do it through GPIO function select.
Re: Possible hardware or MicroPython bug?
I am not against that though I'd favour a 'yes_i_want_that=True' as a 'machine.PWM' parameter to allow it than having to invent some new means of function select.
The problem is someone has to implement it and handle the knock-on effects elsewhere. That it's such a rare issue it is easier to just document it, leave the code as is, and get on with other things which would be more beneficial for the MicroPython community.
The first step for anyone wanting to implement improvements would be to raise it as an issue or discussion, make a proposal and determine the MicroPython team's position on that, then work on a PR which delivers it.
Re: Possible hardware or MicroPython bug?
What do you mean by "having to invent some new means of function select"?
The problem here is a hardware conflict.
The problem here is a hardware conflict.
Re: Possible hardware or MicroPython bug?
BTW can use print on PWM objects:
Code: Select all
>>> print( machine.PWM(9) )
<PWM slice=4 channel=1 invert=0>
>>> print( machine.PWM(25) )
<PWM slice=4 channel=1 invert=0>Re: Possible hardware or MicroPython bug?
If the solution is "If want to use multiple pins, the user should do it through GPIO function select", there has to be some means for a MicroPython user to do that, apply a "GPIO function select", some MicroPython method available to call to allow that to be done.
As far as I could see no such method existed and would therefore need to be invented.
Basically; what are you going to replace the last line here with ... ?
Code: Select all
from machine import PWM
PWM(9, freq=1000, duty_u16=0x8000)
PWM(25, freq=1000, duty_u16=0x8000)
Code: Select all
from machine import PWM, Pin
PWM(9, freq=1000, duty_u16=0x8000)
Pin(25, alt=Pin.ALT_PWM)
Code: Select all
from machine import PWM
PWM(9, freq=1000, duty_u16=0x8000)
PWM(25, freq=1000, duty_u16=0x8000, yes_i_really_want_to_do_this=True)
But 'do nothing except improve the documentation' is still the easiest option.
Re: Possible hardware or MicroPython bug?
Maybe discovered :) , as it has already been invented: https://docs.micropython.org/en/latest/ ... e.Pin.html
As you have seen, can use the constructor or Pin.init method.
By doing "yes_i_really_want_to_do_this=True" way, you still have a hardware conflict.
As you have seen, can use the constructor or Pin.init method.
By doing "yes_i_really_want_to_do_this=True" way, you still have a hardware conflict.
Also look at other peripherals like UART, SPI, I2C etc.As specified above, the Pin class allows to set an alternate function for a particular pin, but it does not specify any further operations on such a pin. Pins configured in alternate-function mode are usually not used as GPIO but are instead driven by other hardware peripherals. The only operation supported on such a pin is re-initialising, by calling the constructor or Pin.init() method. If a pin that is configured in alternate-function mode is re-initialised with Pin.IN, Pin.OUT, or Pin.OPEN_DRAIN, the alternate function will be removed from the pin.
class machine.UART (id, ...)
Construct a UART object of the given id.
class machine.SPI (id, ...)
Construct an SPI object on the given bus, id. Values of id depend on a particular port and its hardware. Values 0, 1, etc. are commonly used to select hardware SPI block #0, #1, etc.
class machine.I2C (id, *, scl, sda, freq=400000, timeout=50000)
Construct and return a new I2C object using the following parameters:
id identifies a particular I2C peripheral. Allowed values for depend on the particular port/board
Re: Possible hardware or MicroPython bug?
I don't understand how you mean. If it's legitimate to route the same channel-slice to multiple pins - as it is, then I don't see that as a hardware conflict, I don't see how it's any different to routing the same channel-slice to that pin using alternative functions, which is what MicroPython does under the hood.
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion