|
Remember that the NES clock rate only limits resolution, not long-term accuracy; done properly the error can be kept within +/- 0.5 clock cycles. For example, if the required delay between bits is 15.5 cycles, bits can be read at a delay that alternates between 15 and 16 cycles resulting in no cumulative error. Or if the delay is 15.25 cycles, delay 15, 15, 16, 15 (15, 15, 15, 16 would be worse since it doesn't spread the error as evenly).
To anyone who's writing software-based serial receive, be sure to wait an extra half bit after you find the beginning of the start bit so that you're sampling the data bits in the middle rather than near the beginning where there's less margin for error.
Even at 57.6kbps, in my NES dev cart loader I have virtually no time to do any processing on the data so I have to just blast it to a buffer. I'm guessing that X-MODEM uses a small block size and requires acknowledgement from the receiver before another block is sent. I can't imagine how you'd keep up on the NES side otherwise.
I have to say that this scheme works very well. The code I usually test does something and then is done, so I have it re-run the loader afterwards so it's ready to receive the next iteration. This allows testing without having to take my hands away from the PC keyboard and mouse. A really cool thing is that the return link from NES to PC can be used to dump debug messages or status information to a terminal while code is running. I suppose one could even put a monitor (debugger) on the NES side which was operated from a terminal on the PC, or maybe have a dedicated PC app which handled user interaction to allowing a simpler monitor program on the NES.
The one I made many years ago for the SNES was nice because the SNES had 128K RAM to upload code to; I haven't added extra RAM to my NES dev cart so all I have is the 8K battery-backed RAM on the hacked Zelda board. What I want is a NES dev cart with a lot of RAM and a small bootloader ROM which is swapped out when my code is running. Memblers, are you making something like this, or just the serial cable?
|