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

Invalid boundary value in pmod_pwm.py #1411

Open
haipnh opened this issue Jan 17, 2023 · 1 comment
Open

Invalid boundary value in pmod_pwm.py #1411

haipnh opened this issue Jan 17, 2023 · 1 comment

Comments

@haipnh
Copy link

haipnh commented Jan 17, 2023

Hi,

I found an invalid boundary value in pynq/lib/pmod/pmod_pwm.py.

def generate(self, period, duty_cycle):
        # ...
        if period not in range(1, 65536):
            raise ValueError("Valid tone period is between 1 and 65536.")
        if duty_cycle not in range(1, 99):
            raise ValueError("Valid duty cycle is between 1 and 99.")
       # ...

On Jupyter Lab, it fails if we execute:

pwm_1.generate(65536,25)

Error message:

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/lib/pmod/pmod_pwm.py in generate(self, period, duty_cycle)
     95         """
     96         if period not in range(1, 65536):
---> 97             raise ValueError("Valid tone period is between 1 and 65536.")
     98         if duty_cycle not in range(1, 99):
     99             raise ValueError("Valid duty cycle is between 1 and 99.")

ValueError: Valid tone period is between 1 and 65536.

Another failed point:

pwm_1.generate(10,99)

Caused:

/usr/local/share/pynq-venv/lib/python3.8/site-packages/pynq/lib/pmod/pmod_pwm.py in generate(self, period, duty_cycle)
     97             raise ValueError("Valid tone period is between 1 and 65536.")
     98         if duty_cycle not in range(1, 99):
---> 99             raise ValueError("Valid duty cycle is between 1 and 99.")
    100 
    101         self.microblaze.write_mailbox(0, [period, duty_cycle])

ValueError: Valid duty cycle is between 1 and 99.

Best regards,
Hai Pham

@mariodruiz
Copy link
Collaborator

Hi @haipnh,

We appreciate if you can contribute the solution to this issue.

Mario

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

2 participants