Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: port manipulation instead of dac output while reading from sd

  1. #1
    Junior Member
    Join Date
    Jun 2017
    Posts
    8

    port manipulation instead of dac output while reading from sd

    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!!!

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,272
    Quote Originally Posted by raindrop View Post
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •