DrAzzy:
It looks like they always use the MISO spi pin as one of those pins. It's not clear to me whether this is a requirement, or a convention (and it's not immediately obvious from the code - I can see no clear evidence that it's a requirement, but then why do they mention that it's the MISO pin?)
MISO is used because it is very convenient (except when the target needs SPI communications).
There are no special hardware requirements. Any digital I/O pin can be used.
Can someone explain to me what exactly TinyDebugKnockBang actually does?! The readme is blank, and the only description of it's functionality is "Serial like debugging for processors with an uncalibrated / inaccurate clock."
It is a combination of hardware and protocol.
A single line is used for communications.
The line idles high using a pull-up. The internal pull-ups are enabled on the programmer and target so an external pull-up is not needed.
When the target has data to send, it pulls the line low for 13 µs. This is enough time for the programmer to respond to a pin-change interrupt. The target then releases the line. That sequence is a "knock".
The programmer responds by pulling the line within 6 µs, holding the line low for 6 µs, then releasing the line. That sequence is a "hello". In an unpublished version, the "hello" has been eliminated. The "hello" solves a very minor problem and creates a major annoyance so I took it out.
After a short delay (24 cycles on the target), the target owns the line and the programmer is waiting for the first frame.
Each data bit consists of a toggle (1 µs width) followed by the bit value (>= 2 µs width). (This is the "bang" part of the name; as in "bit-bang".)
Each data byte consists of a string of eight bits.
Each frame consists of a one-byte-length followed by that number of bytes. A length of zero indicates the target has nothing left to send.
A one-byte-command is sent first. If the command has no data (like CMD_WRITE_CRLF) the next frame is zero length indicating the target is finished. If the command has data (like CMD_WRITE_BYTE) the next frame contains the data.
When the target is finished, as I said earlier, a zero length frame is sent then the target lets the line idle high.
This has advantages over Serial and its ilk...
• The 1 µs + 2 µs width of the data bit allows the target clock to be ±20%. Well within the range of a factory fresh target.
• The target does no formatting. This dramatically reduces the memory and CPU requirements for the target.
• The protocol can easily be extended. For example, the latest version has commands to turn on / off a tuning clock.
• The timing can easily be extended. Right after the "hello" the target outputs a "sample point". The programmer can use that to adjust the data bit timing. The latest version has a "slow timing" mode that allows Knock-Bang to work when the target is running at 128 kHz.
• Any digital I/O pin can be used.