Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_pwm_period(): PWM load detection is not working correctly #31

Open
neuron-whisperer opened this issue Jan 11, 2025 · 0 comments
Open

Comments

@neuron-whisperer
Copy link

I'm developing an application involving a Raspberry Pi 5. I have the Pimoroni I/O expander connected to the I2C GPIO pins, and in general the board is working fine. However, every once in a while, this happens:

>>> ioe.set_pwm_period(60000) Timed out waiting for PWM load!

However, if I invoke that function with wait_for_load=False, the I/O expander behaves just fine, including controlling PWM devices connected to those pins.

Looking at this code:

    def pwm_load(self, pwm_module=0, wait_for_load=True):
        # Load new period and duty registers into buffer
        t_start = time.time()
        self.set_bit(self._regs_pwmcon0[pwm_module], 6)  # Set the "LOAD" bit of PWMCON0
        if wait_for_load:
            while self.pwm_loading(pwm_module):
                time.sleep(0.001)  # Wait for "LOAD" to complete
                if time.time() - t_start >= self._timeout:
                    raise RuntimeError("Timed out waiting for PWM load!")

    def pwm_loading(self, pwm_module=0):
        return self.get_bit(self._regs_pwmcon0[pwm_module], 6)

...it looks like get_bit() is returning 0/False even though the PWM controller has been correctly configured and is behaving as expected.

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

No branches or pull requests

1 participant