custom output

Status
Not open for further replies.

rafzael

New member
I'd like to create a kind of tone link to a pulse oscillator from the audio lib. In other words, I'd like to create an output object (or twist an existing one) and digitalWrite(high) if the incoming signal is >= 0 and digitalWrite(low) when the signal is < 0.
Of course this has to be compare at the audio rate (44100) so it isn't possible to do it within the update function that run every 2.9ms . I try to understand how the 128 samples array is used to read data at audio rate in view to compare it to zero and ask for digitalwrtie high or low depending on the currently read value but I have to admit that the code in outpout objects is a bit obscur to me.
Any help is welcome, thanks.
 
Ok, thanks, Gonna give a try but I suspect that the audio lib use priority time interrupts that could influence the rate of other timers.
 
Ok, thanks, Gonna give a try but I suspect that the audio lib use priority time interrupts that could influence the rate of other timers.

No, it uses a lower priority interrupt. Outputs and Inputs are working with DMA which does not need interrupts for the 44kHz timing - they fill their buffers with a much lower rate.
 
Maybe this could be done with 2 DMA channels?

You'd configure the PDB to trigger DMA, as is done with the DAC output. But instead you'd trigger 2 DMA channels (or trigger 1 channel and configure that channel to trigger another), rather than triggering a single channel.

Then on each 128 sample update, you'd fill two 128 byte buffers with bitmasks for whatever pin you want to control. The DMA channels would copy those bitmasks to the GPIO set and clear registers on each audio sample. So if your update code has filled the 2 buffers with the appropriate bitmasks, the pin will be changed automatically at the audio rate, just like how the DAC is updated.
 
Status
Not open for further replies.
Back
Top