I'm tinkering with the pigpio [C] PWM functions and get ``pio bad dutycycle (nnn)'' messages while cycling an LED with increasing/decreasing gpioPWM() values.
As always, any help will be greatly appreciated.
Code:
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <pigpio.h>
#include <unistd.h>
unsigned int PWM_PIN = 21,
FREQ = 1000,
RANGE = 125,
PWM = 255,
DELAY = 1E4;
int main(int argc, char *argv[]) {
if (gpioInitialise() < 0) {
fprintf(stderr, "GPIO initialization failed...exiting.\n");
return(1);
}
gpioSetPWMfrequency(PWM_PIN, FREQ);
gpioSetPWMrange(PWM_PIN, RANGE);
while (1) {
for (int i = 0; i < PWM; i++) {
gpioPWM(PWM_PIN, i);
usleep(DELAY);
}
for (int i = PWM; i > 0; i--) {
gpioPWM(PWM_PIN, i);
usleep(DELAY);
}
}
//printf(">>>\n");
//getchar();
//gpioTerminate();
return 0;
}