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

PWM code is taking 'No such device' error. #161

Closed
system-linux opened this issue Oct 14, 2024 · 4 comments
Closed

PWM code is taking 'No such device' error. #161

system-linux opened this issue Oct 14, 2024 · 4 comments
Labels

Comments

@system-linux
Copy link

system-linux commented Oct 14, 2024

Using this library with my Raspberry Pi 5, I ran the ready-made example code below using sudo:
`Rust
use std::error::Error;
use std::thread;
use std::time::Duration;
use rppal::pwm::{Channel, Polarity, Pwm};

fn main() -> Result<(), Box> {
// Enable PWM channel 0 (BCM GPIO 18, physical pin 12) at 2 Hz with a 25% duty cycle.
let pwm = Pwm::with_frequency(Channel::Pwm0, 2.0, 0.25, Polarity::Normal, true)?;
// Sleep for 2 seconds while the LED blinks.
thread::sleep(Duration::from_secs(2));
// Reconfigure the PWM channel for an 8 Hz frequency, 50% duty cycle.
pwm.set_frequency(8.0, 0.5)?;
thread::sleep(Duration::from_secs(3));
Ok(())
}`

But this code does not work and gives the error Error: Io(Os { code: 19, kind: Uncategorized, message: "No such device" }).
Note: I ran the program with sudo due to an permission error.

@golemparts
Copy link
Owner

Apologies for the late response. This type of error usually means PWM hasn't been properly configured. Make sure you have added dtoverlay=pwm to your /boot/firmware/config.txt (and reboot the Pi after).

@golemparts golemparts added the pwm label Oct 30, 2024
@golemparts
Copy link
Owner

@system-linux were you able to resolve this issue?

@golemparts
Copy link
Owner

Closing this due to inactivity. If you're still encountering this error, and it's not a Raspberry Pi OS configuration issue, please let me know and we can revisit the matter.

@system-linux
Copy link
Author

I'm so sorry, I didn't have time to reply. I don't have time to try this anymore in my project because we decided to use C++ wiringPi. So I haven't had a chance to try it yet.

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

No branches or pull requests

2 participants