Hi all, I was using Raspberry Pi3b and now I would like to try hardware pwm on the Rock Pi4b. With the bcm2835 chip, it reads “The PWM clock can be set to control the PWM pulse widths. The PWM clock is derived from a 19.2MHz clock. You can set any divider, but some common ones are provided by the BCM2835_PWM_CLOCK_DIVIDER_* values of bcm2835PWMClockDivider.” http://www.airspayce.com/mikem/bcm2835/
What about the hardware clock on the rockpi4b?
I would like to use libmraa to drive the hardware pwm to 1 MHz for some 3 wire laser pointer. Are there any example codes similar to pigpio as in http://abyz.me.uk/rpi/pigpio/cif.html#gpioHardwarePWM
Hi Jack,
Thanks and I tried the c example that comes with mraa.
If I set PWM_FREQ 1000, it works ok and I have a 1kHz square pulse. But if I set PWM_FREQ 100, it returns with MRAA: Invalid resource.
Hello rolly,
The libmraa has not support repeatedly change pwm clock frequency.
Change source code:
/* PWM period in us */ #define PWM_FREQ 100
Compiled it, reboot your rock pi 4 and then run the program,you can change pwm period to 100ms.
You can call the mraa_pwm_get_max_period and mraa_pwm_get_min_period functions to get current pwn output max and min period.
Hi Jubian,
Thank you and it works to 1 MHz with
/* PWM period in us */ #define PWM_FREQ 1
I suppose this is the fastest I can get with mraa as the unit is in microsecond?
Anyway, I found the pigpio library is easier than mraa with pwm, anyone tried to port the pigpio to rockpi4?