I think I'm starting to penetrate why my script doesn't work and why I'm missing bytes. The problem is that it doesn't wait for the signal to come, while it should. Although the Teensy frequency is 24 times bigger than GB's still a clock signal from GB may come when Teensy is busy doing something else (checking edge for example, or writing to serial port). This I believe might be the root of the missing bits problem.
The solution may be using interrupts, however rvan reported he was unsuccessful. Also rvan, could you please share you code?
The interrupts based workflow may look like this:
1. Interrupt for CLOCK signal, the handler will read pixel data from the respective pins and update pixel offset counter
2. Interrupt for HSYNC, the handler will reset offset counter
3. Interrupt for VSYNC, the handler will send the frame to PC and reset offset and line counters
Another approach will be using Teensy as mere logic analyzer, then the workflow will be somewhat simplified version of the above. Each interrupt handler will send a byte to pc. In case of data it's a pixel byte in case of sync signals it some byte like F0 for VSYNC and E0 for HSYNC.
There's one more concern though. What if a signal arrives while Teensy is handling the previous interrupt? This may me the reason why rvan's attempt didn't succeed. But I'd really like to see the code in order to avoid wasting time on re-doing something that has been done already.
Last edited by friendofmegaman (Apr 25, 2014 12:21 am)