I’m trying to implement a wav player using the PWM output, on pin33 of my xavier nx.
I could test the PWM using SysFS, as well as sample code from jetson-gpio library
The idea is to output a high frequency PWM (~62.5kHz), change the duty cycle for every audio sample, then use a low pass filter to cut off the high frequency component and keep only the audible frequencies.
However, changing the duty cycle through SysFS seems to be taking lots of time.
Each call to the change duty cycle function takes about 196us. (most time is spent on the write() call the duty_cycle file)
Meaning my player can only write ~5100 audio samples/second.
Meanwhile the audio file sample rate is 44.1kHz.
I tried to read the pwm sysfs driver under drivers/pwm/sysfs.c hoping to find something that causes the delay but no luck so far.
Is there any faster way to change the duty cycle of PWM?
Any support would be greatly appreciated.