On 8 Dec 2009 at 18:12, Keith M wrote:
My amiga disk reader doesn't sample at all. I
look for falling edges
of the pulses, clear a timer, look for the next edge, and calculate
the time difference between two pulses. The time between pulses
define the data, and I write out the associated data pattern to
memory.
I don't even do that with the AVR-based one. I set one of the
counters to free-run in "capture" mode, where the edge of a pulse
causes the contents of the timer to be latched into a register. I
then store the difference between that count and the previous one,
modulo 256. A very short loop with no program-dependent latencies.
The AVRs also feature a 'noise filter" that drops any pulses less
than 4 clocks wide. I've left the filter enabled, and it seems not
to interfere with normal reading.
Similarly, writing involves operating the timer in PWM mode. As long
as the terminal count register is kept updated, everything works
flawlessly.
Most DSP chips also have timer capture mode, but can run the timers
substantially faster that 16 or 20 MHz.
--Chuck