Reading a file backwards
Hi there!
I'm working on a project wherein I'm trying to play an audio file in reverse. I'm using freeRTOS, fatFS, and a 4-wire SDIO setup, and am doing this little file read dance where I:
- f_lseek() to the end of a file
- calculate how many bytes I want to read
- f_lseek() backwards
- do the read()
- goto 2
Then, later, I reverse my audio samples.
I'm experiencing some odd behavior that I don't understand, however. To try to wrap my head around it, I toggle a GPIO each time I start the above cycle. I would expect - when probing this GPIO with a scope - to see a reasonably constant square wave period that would help me understand how long the whole operation takes.
What I see, however, is something different: I see a few high/low cycles, then a period of what looks like inactivity, then another section of high/low cycles:

I'm still coming up to speed with my understanding of fatFS, but I'm curious what might cause these 'pauses'?
I understand that what I'm doing - constantly seeking backwards in a rather large (47MB) file is ill-advised: I think what I'm doing is constantly traversing a tree from the beginning each time I do this seek (?). But it's not clear to me why this might take dramatically longer for some cycles and not others.
I've also got some browser tabs open here trying to understand what other options I might consider for this (e.g. I wonder if a different filesystem might be more suited to this task? LittleFS?). But rather than just chalking this up to "this doesn't work", I'd like to understand more deeply what I'm experiencing.
Thanks for any insight anyone may offer!
