Skip to content
Discussion options

You must be logged in to vote

You're not doing anything wrong, it's just that these APIs were not designed to handle this case -- machine.PWM() needs to be given something that is exactly a Pin. Internally it checks the equivalent of type(p) == machine.Pin, not isinstance(p, machine.Pin)`.

It would actually be possible to make this work (although it needs to be fixed in many places across each of the ports), and I'd argue that what you're doing should work. Perhaps raise a feature request?

(FWIW, the way to fix this, on Pico at least, is in mp_hal_get_pin_obj to use mp_obj_cast_to_native_base() rather than mp_obj_is_type.)

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@cve2022
Comment options

@peterhinch
Comment options

@rkompass
Comment options

@cve2022
Comment options

Answer selected by cve2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants