Skip to content

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Mar 13, 2019

PWMOut was reading a supplied bool arg as an int, so it was almost always True.

Also minor fix to make sure SWRESET is finished before proceeding.

Fixes #1626.

@dhalbert dhalbert requested a review from tannewt March 13, 2019 01:29
@dhalbert
Copy link
Collaborator Author

@kevinjwalters has tested this successfully: see #1626.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Good find! Thanks @kevinjwalters for the bug and verification.

@tannewt tannewt merged commit b4601a3 into adafruit:master Mar 13, 2019
@dhalbert dhalbert deleted the pwmout-var-freq-bug branch March 13, 2019 18:29
@kevinjwalters
Copy link

If it was always True then why did my code sometimes work and initialise both PWMs?

Is the bool 8 bit and the int 32 bit so it's reading 24 extra bits from somewhere? Would the case where mine worked be if those others 24 bits happened to be 0 for both instantiations?

@dhalbert
Copy link
Collaborator Author

"always True" was wrong. It was actually almost always True, but not quite all the time, depended on what junk was left over in the memory location.

@kevinjwalters
Copy link

kevinjwalters commented Mar 15, 2019

Do you have an automated way of checking for type discrepancies in the interface between the python and C code? If any of these memory addresses are written to (return values?) then getting the wrong type could be far more hazardous.

I glanced at the code and perhaps this particular one is a problem solely within the C code between the declarations and extraction via a union? Is there scope for bugs in Python <-> C too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pulseio.PWMOut() instantiation fails sometimes with constant same frequencies on CPX
3 participants