0

I am trying to use pwm on GPIO pin 40 but I have been unsuccessful so far. I am using pwm as device tree overlay in my config.txt dtoverlay=pwm,pin=40

After that I tried performing the below actions

root@rpi3:/sys/class/pwm/pwmchip0# echo 0 > export

root@rpi3:/sys/class/pwm/pwmchip0# echo 1000000 > pwm0/period

root@rpi3:/sys/class/pwm/pwmchip0# echo 500000 > pwm0/duty_cycle

root@rpi3:/sys/class/pwm/pwmchip0# echo 1 > pwm0/enable

I tried doing the same thing on channel 1 but still nothing. (I have an Oscilloscope connected to the pwm line)

I added dtoverlay=pwm,pin=40,clock=1000000 and turned my audio off in config.txt

But I am still unable to see a pwm pulse. Why is that? The Documentation, states me to setup the clock before using it. So How do I setup my clock? Also Software PWM works via python code works. But that is not somethings that I want. Since that requires me to run a python script on an infinite loop.

3
  • Are you sure your clock settings and dutycycle are acceptable to that dtoverlay? As an aside you could use pigpio to start the PWM pulses and then exit the program - that would leave PWM running.
    – joan
    Commented Dec 11, 2019 at 9:42
  • @joan How do I know the acceptable dutycycle and clocksettings. Right now by trial and error it won't let me go below a certain value. So Thats about it. And I haven't looked in to pigpio Commented Dec 11, 2019 at 14:56
  • @joan please add your comments as an answer. I think it is a great suggestion Commented Dec 11, 2019 at 15:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.