PWM Pins behaving inconsistently
I'm on an Up Board. When I type uname -a:
Linux splash 4.15.0-37-generic #40~upboard04-Ubuntu SMP Thu Feb 14 13:49:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
I'm trying to use the 2 PWM pins to control the GB value on an RGB LED, but the PWM pins are behaving inconsistently.
I'm following the example from the pinout guide:
echo 0 > /sys/class/pwm/pwmchip0/export
echo 3413333 > /sys/class/pwm/pwmchip0/pwm0/period
echo 1706667 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
My understanding is that when I echo 1 into the "enable" folder it should enable that pin and that "echo 0" into that pin should disable it. The behavior that I'm expecting is that the LED will be turned on when the pin is enabled and turned off when the pin is disabled. This is not always the case however. Sometimes if the enable folder contains a 1 and I echo a 0 into it, the LED will get brighter rather than turning off. Sometimes if the file contains a 1 and I echo a 1 and then echo a 0 it will turn the LED off.
I need the LED to turn on and off reliably and get the PWM pins to behave in a predictable manner. Are my assumptions about the enable/disable functionality correct, and if so any ideas about why it is not behaving consistently? Is there something about trying to use both PWM pins that could be causing erratic behavior?