Freaks,
Working with some code today reminded me of a discussion I had with a fellow student during last semester. My friend, as part of his fourth year electronics project, was trying to create a reliable one-way link between two AVRs. One constraint was that he had only had two GPIOs available (no hardware UART).
My idea was to keep things very simple, to ensure he was able to code it without much difficulty, and to ensure that bytes weren't missed.
Of the two lines, one was data, the other clock. The Data line was controlled by the master, while the clock was controlled by the receiver (slave). When idle, both lines are pulled high.
To signal that the master wishes to send a byte to the slave, it pulls DATA low. The slave, seeing the transition when it is ready, clocks in the byte and the master idles DATA again.
Idle:
[AVR 1 - Master] [AVR 2 - Slave] ________________ _______________ (VCC)--|----DATA----| |----CLOCK---|--(VCC)
Master waiting for transmission:
[AVR 1 - Master] [AVR 2 - Slave] ________________ _______________ (GND)--|----DATA----| |----CLOCK---|--(VCC)
Sending Data
[AVR 1 - Master] [AVR 2 - Slave] ________________ _______________ (Data)--|----DATA----| |----CLOCK---|--(Clock)
This scheme worked great - the system ensures that both AVRs are ready before the data exchange takes place. Discussing things further, I came up with an extension; use the same system as before, but allow for half duplex communications in both directions. The scheme is exactly the same, except one AVR pulls its data line low, and the other AVR clocks in the data on the opposite communication line.
Idle:
[AVR 1] [AVR 2] ________________ _______________ (VCC)--|----DATA1---| |----DATA2---|--(VCC)
AVR 2 waiting for transmission:
[AVR 1] [AVR 2] ________________ _______________ (VCC)--|----DATA1---| |----DATA2---|--(GND)
Sending Data to AVR 1
[AVR 1] [AVR 2] ________________ _______________ (Clock)--|----DATA1---| |----DATA2---|--(Data)
AVR 1 waiting for transmission:
[AVR 1] [AVR 2] ________________ _______________ (GND)--|----DATA1---| |----DATA2---|--(VCC)
Sending Data to AVR 2
[AVR 1] [AVR 2] ________________ _______________ (Data)--|----DATA1---| |----DATA2---|--(Clock)
Now, I'm smart enough to realize that something this basic has already been invented many times before. Can someone point me in the direction of the official name for this protocol?
- Dean :twisted: