I want to generate some signal on GPIO pin on Raspberry PI Zero W using DMA control blocks and PWM to pace data. However I faced with some problems while trying to generate signal at ~1MHz.
When I configure timings to generate 1us high state followed by 1us low state in loop (basically looping DMA control blocks) I see following picture on GPIO pin output:
In general it generates 1us pulses but sometimes something goes wrong and DMA changes GPIO state with wrong timings. It looks like this "interrupts" happens periodically each ~65us (about 16kHz).
Here is minimal reproducible code that generates signal on GPIO pin 23 and compiles fine on Raspberry PI Zero W: https://www.codepile.net/pile/1odpzloW (I'm just modified example from https://iosoft.blog/2020/05/25/raspberr ... ogramming/)
Where is the problem?
3 posts • Page 1 of 1
Well, the BCM2835 DMA-gated PWM capability does support close to microsecond-resolution in producing waveforms, it's just not well-socialized. The pigpio GPIO library for the RPi encapsulates it in it's waveform functions, and I'm using that successfully to modulate the NMRA DCC signal for model train control.
Link to the pigpio library: http://abyz.me.uk/rpi/pigpio/
Link to what appears to be a decent StackOverflow thread on how it works: https://stackoverflow.com/questions/504 ... a-dma-work