Thanks for the reply!
BigDumbDinosaur wrote:
I’d write it as...
In writing I/O routines, it’s generally helpful to look at the overall picture before obsessing on how fast a particular code segment can run. Even though my routine is slightly slower than yours, it will still outrun many SD cards, especially if your clock rate is significantly faster than 1 MHz. At the same time, there are six instructions, versus 15, to help save some space.
But I don't need to save space right now.
Unrolling is the least I can do to increase the SD read speed.
I can stream off the SD card a 47 FPS average, 4 color, Bad Apple video with vsync off with my current code.
That is 23,829 bytes a second streaming on average.
I'm using a class 10 SD card and my clock is 5Mhz, but with VGA halting I only get 1.4Mhz
1,119,963 cycles of my 1.4 million cycle a second CPU budget is spent just reading these bytes.
While my source is 30 FPS, the more complex frames are more bytes and take longer to render.
Some sequences are still less than the full speed I'd like. I am only doing square wave music, when I add digital I'll need even more data off that SD card.
Also, I only have 7.5k available for a read buffer and that just might not be big enough to smooth out both the video and handle audio.
Given this I think I might need a faster SD read (or to read less in the first place with a better encode) because I am streaming video data from the SD card as fast as I can now and I am already too slow for what I will want.
BigDumbDinosaur wrote:
[color=#000000]
That said, what is your assurance that each time you read from VIA_PORTA that valid data will be waiting? In other words, what is handshaking your transfer from the SD card to the VIA?
I put the SD card in READ_MULTI_BLOCK mode.
When in this mode every pulse on the clock puts a bit on MISO.
With VIA PORT A setup to pulse CA2 on reads every read of the port puts a bit in bit 0 of the port.
Once started the SD card will stream bits forever.
As long as you take into account a 10 byte CRC message every 512 bytes anyway.
I'm working on a better encoder/decoder that will help quite a lot by needing less bits, but with the digital audio I want to stream the math says I need to try to work this problem from both ends.
Thanks!