I have a project that requires streaming data to SD card. The data consists of 8 bit-wide channels of 10 bit data clocked in at 23.4 MHz. One frame is 60 clocks. I did some tests (stock code - no data capture) with a fast SD Card using the 'bench' example in the SDFat library and I get around 22 MB/sec. So doesn't look good at first glance, especially since I need to add data capture, buffering, etc. Thinking about it, I see there's a fair amount of unnecessary stuff in the data stream and since port reads are 32 bits wide. I can reconfigure the data stream to be 32 bits wide with 10 bits per frame. This only requires a clock rate of 3.9 MHz. Now of course I'll need reconfigure data outside the Teensy as it will take too many cycles. Also I realize that the 4.1 does not have a contiguous 32 bit port brought out, so I'll need to roll my own board. This is ok as this thing has to be as small as possible.
In order to give as the maximum amount of time to the SD card code, I figure I need to acquire data via interrupt . I have seen in several places in the forum that the stock interrupt code is slow. Then I found this thread:
which looked promising. So I basically duct-taped that to the Bench example to see how that would work using a big shared buffer. I can just get to 4 MHz with this so, I am optimistic. I need to dig in and see where I can speed things up.
So I have a few questions:
1. I'm wondering if DMA would be better? I need to do the homework on that, but it would be helpful to know if it's worth looking at in detail. Can one move port data into memory with an external clock using DMA?
2. The incoming data clock is fixed to 23.4Mhz. I'm think I could save an oscillator if my board runs the Teensy at 23.4Mhz instead of 24Mhz. I figure this will screw up timers and baud generators, which is ok I think. But I assume it might mess up the USB?
3. I didn't see any other threads that were real similar to what I'm trying to do, but if missed something, please let me know.
And I want to thank everyone that contributes to this forum and the libraries. It let me make a lot of progress quickly. I was also worried about how making my own T4.1 would work. Then I found the page on PJRC where Paul sells the boot chip and has great advice on how to lay out the board and run tracks. Wow, simply amazing.
In order to give as the maximum amount of time to the SD card code, I figure I need to acquire data via interrupt . I have seen in several places in the forum that the stock interrupt code is slow. Then I found this thread:
which looked promising. So I basically duct-taped that to the Bench example to see how that would work using a big shared buffer. I can just get to 4 MHz with this so, I am optimistic. I need to dig in and see where I can speed things up.
So I have a few questions:
1. I'm wondering if DMA would be better? I need to do the homework on that, but it would be helpful to know if it's worth looking at in detail. Can one move port data into memory with an external clock using DMA?
2. The incoming data clock is fixed to 23.4Mhz. I'm think I could save an oscillator if my board runs the Teensy at 23.4Mhz instead of 24Mhz. I figure this will screw up timers and baud generators, which is ok I think. But I assume it might mess up the USB?
3. I didn't see any other threads that were real similar to what I'm trying to do, but if missed something, please let me know.
And I want to thank everyone that contributes to this forum and the libraries. It let me make a lot of progress quickly. I was also worried about how making my own T4.1 would work. Then I found the page on PJRC where Paul sells the boot chip and has great advice on how to lay out the board and run tracks. Wow, simply amazing.