Teensy 3.1 - Correct way to use interrupts on received Serial data

Status
Not open for further replies.
Best is to write to SD 512Byte packets (or a multiple of 512) - that's the internal storage block size for SD Cards. Any other size will be slower.
 
Thank you for your suggestions!!!
When you say, I need to write 512 bytes packets, do you mean sd unit size?
Capture.PNG
in my case it's 32 Kbytes

I'm using SD.h to write file, is there a proper way to write data blocks?
my example is:
Code:
...
    static Queue  queue1(sizeof(int), 50000); // Instantiate queue
    static const int SD_CLASTER_SIZE = 512;

    while((!queue1.isEmpty()) && (queue1.getCount() > SD_CLASTER_SIZE)){
      queue1.pop(&incoming);
      rawFile.write(incoming);
    }
    rawFile.flush();
    
...
 
Looking for a solution to the same issue. I can't use the suggestions and really need an interrupt because the device I have to talk with is the one polling me with "do you have something to say?" and I have to respond within 2ms of the request. My program is pretty busy collecting data from various sources and logging them to an SD card plus sending processed data to 2 devices (this polling one being one of them).

Without the SD logging I'd have no problem handling it in the main loop since it runs below 400us or so that way, but logging takes up to 5-10ms so when I throw it in I have no chance of responding to the polling device in time.

I'm currently cheating with an interrupt on the falling edge of the serial line and an awful 200us delay in the interrupt, it works but it's dirty.
 
Status
Not open for further replies.
Back
Top