port manipulation instead of dac output while reading from sd

Status
Not open for further replies.

raindrop

Member
Hi to all.
I have teensy 3.6 with on board sd card module and would like to use the sdfat library with available sram for buffers 204800 bytes that means that i can use 400 buffers of 512 bytes for each block read from sd.Microcontroller audio players have two buffers,one is pushed out(DAC values) while the other one is filled again before the first one comes to the end.Thats why 44.4Khz is the maximum 8bit wav playing so none of the buffer underflows with the result of disturbing output frequency.Well in my case istead of pushing DAC values i want to push bytes with port manipulation.Could someone share a code similar to audio player and explain me where the reads take place,also how and where the buffer exchange (ping-pong) is done and replace the DAC output with port manipultion??The main problem i face is that the output frequency is not stable because of the sd card latency for that reason the reads have to be done in "parallel" so that always have available bytes to push out in a stable rate (maybe with a timer interrupt at 40Khz).I really need help to complete my thesis,thanks a lot!!!
 
Well in my case istead of pushing DAC values i want to push bytes with port manipulation.Could someone share a code similar to audio player and explain me where the reads take place,also how and where the buffer exchange (ping-pong) is done and replace the DAC output with port manipultion??

Maybe the OctoWS2811 code can help? It writes to the GPIO port using DMA, but the concept is pretty much the same for reading.

In the audio library, the "ping pong" is actually done using a single buffer and a feature of the hardware to generate an interrupt when the half-way point is crossed. The interrupt code copies half the buffer data, while the other half continues being used by the DMA. Look at any of the input or output objects to see this DMA code.
 
Status
Not open for further replies.
Back
Top