I'd like to drive chains of WS2812 LEDs with the 'Pi using DMA.
Timing of the LEDs must be precise. I need long bursts of of '0' and '1'
without much jitter at 800khz. Several kbytes in 10-20msec, all in one
packet. One-wire, similar to Manchester encoding.
Normal bitbanging or abusing the UART is error prone. Scheduling gaps
destroy the timing. Especially the pause every 21usec. Would the DMA
continue across these pauses?
Pointers welcome.
Thanks in advance, and thanks for sharing v4craspi!
cheers, JW-
I initially developed v3c-raspi to talk I2S with 16 microphones for sound field capture.
I couldn't get it to drive a clock pin much past 2MHz, and so dropped the sample rate from 44.1KHz to 22.050KHz, but there was some fluctuation in the capture rate, in the order of a few percent.
The code splits the allocated memory into two banks and sets up the DMA round robin scheme to go through the first bank a page at a time, then the second bank.
The pages in the banks are sorted by physical address, which is unrelated to their virtual address.
The code running on the ARM chip periodically checks the physical address of the DMA channel.
Once this address changes from one bank to the other we know that a bank is filled and we can hand it over for processing.
I noted that there is some variation in sample speed and this is where it shows itself.
Now whether this is because of a gradual drift or some number of descrete pauses, well I'd guess it depends on what the CPU/OS is doing at the time.
In one test I included a DMA transfer of some Broadcom free running timer register in the stream so I'd know what the reason for the variation in speed was, but I got sidetracked and it's still on my TODO list.
It looked pretty consistent at that level of detail but I was doing visual inspection and a graph would have been better.
The clock itself might have some variance in its speed too, but I don't know off hand how accurate it is claimed to be.
The examples/references use the PWM for timing/delay purposes, so you can do that to pace the GPIO transfers, or even serialise the data out using DMA through the PWM.
Regards,
Philip Ashmore