Quote Originally Posted by spfautsch View Post
So here's an arduino sketch (mega 2560 minimum required due to 2+ hardware serial ports) to log to an SD card in a Y-body. Representative logfiles included. As with my previous example sketch, this is a minimalist, down-and-dirty representation of functionality. I will probably not post a lot more about it unless there are users with interest, but wanted to put it up for the possible benefit of NomakeWan. At the very least it will demonstrate how to use a hardware timer / counter (timer 3 on the mega) to implement a delay between ALDL receive and microcontroller transmit.
Just to make sure I know what's going on here, you have this line:

Code:
#define TCNT3_TICKS 28    // 62.5us each 24 = 1.5ms
...
OCR3A = TCNT3_TICKS;   // set timer0 compare match register A
...
TCCR3B = (1 << WGM32) | (1 << CS32) | (1 << CS30);
If I'm understanding this correctly, isn't this actually 64 microseconds per tick, thus making 28 ticks 1.792 milliseconds? Check my work.

System Clock: 16000000 Hz
TCCR3B = 16000000 / 1024 = 15625 Hz
1 tick / 15625 Hz = 64 microseconds/tick
64 microseconds * 28 ticks = 1.792 milliseconds

Is there an errata or something I'm missing? As you know, I've not addressed timers before, so I want to be sure.