sd card data flow

Status
Not open for further replies.

raindrop

Member
Hi!!
Well i have a project that i need to read constantly bytes from a binary file "byte" buf=file.read() from sd card and make an output with port manipulation (PORTD = buf, ... or PORTD = file.read() inside a loop) at some stable frequency.

I have read that because of the sd card latency the file.read() command will not excecute at the same time everytime so the output frequency will not be stable.Is this latency happens when i open the file once read until the end with a loop and then close the file???

If so,the other solution is to read from sd card each 512 bytes and store each byte into a buf array with the help of a struct according to that https://hackingmajenkoblog.wordpress...on-an-arduino/ .The problem now is that each time i read 512bytes i have to wait for those to come plus the sd card read latency.Is it possible to make two buffer arrays of 512bytes each -> fill the first one -> start port manipulation with the first array inside a timer interrupt with frequency of (10 or 20Khz or more) so the output always have stable freq while in another loop try to fill the other array??I mean is it possible to interrupt the "file.read(buf,size of(512))" command without issues??

If so how i can deal with smooth data rate and have a stable frequency??

I believe that the same problem occurs with microcontroller audio players which they play wav from sd card.Please help me,thanks in advance!!!
 
This was cross-posted in Project Guidance. Please see that thread for replies. I'm closing this thread to consolidate the conversation.
 
Status
Not open for further replies.
Back
Top