

Instead of one bit per second I used 9,600 bits per second (baud), so each bit takes about 104 microseconds. The oscilloscope trace in Figure 5-1 is a real example of an AVR transmitting the digit 10 to my computer. He then flips the bit-ordering around, and sees that Alice has sent the number 10! After the first blink, he sees off, on, off, on, off, off, off, off, and then the LED stays on for a while. It blinks off for a second-the start bit! Now once every second after the start bit, he notes down whether the LED is on or off. How does Bob tell when the transmission begins and ends? They’ve agreed to wrap the eight bits with two extra bits: a start bit, which will always be a zero so that you can tell when the transmission starts, and a stop bit, which is a one.īob is sitting at his end, staring at the LED, when he sees the LED blink. This is the baud rate-how often the voltage is allowed to change on the line, and conversely how often the receiver needs to read in a new voltage. Let’s say they choose to signal once per second. Next, they need to agree how often Alice presses or doesn’t press the button.

First they need to decide on an encoding: they agree beforehand that a button press (a zero-volt signal on the wire) indicates a zero, and no-press (five volts) indicates a one, and that they’ll send the numbers least-significant-bit first.
#Coolterm 104 framing error serial#
So instead she writes out 10 in binary, 0b00001010, and sends a corresponding pattern of flashes.īob and Alice have to agree on a bunch of things beforehand for this to work-the serial protocol.

Now, she could send the number by just blinking the LED off 10 times, but that system’s going to break down when she wants to send the number 253, or worse, 64,123. On Alice’s side of the wire, there’s a switch connected to ground, and on Bob’s side, there’s also an LED so that he can see what the voltage on the wire is by whether or not the LED lights up.Īlice is going to send the number 10 to Bob by pressing her button, grounding the wire, and turning off Bob’s LED on the other side. For concreteness, let’s say that the wire’s got a pull-up resistor on it so that it’s constantly at five volts. Let’s say Alice wants to send the number 10 to her friend Bob over a wire. To understand what’s going on with UART serial, start by thinking of two people who want to talk to each other by sending voltage signals over a few wires. For now, we’ll limit ourselves to the most common serial mode-universal asynchronous receive and transmit (UART) serial. We’ll get into a lot more of the nitty-gritty of other serial protocols in Chapter 16 and Chapter 17. The rules for encoding data into voltage pulses and decoding the voltage pulses back into data is called a serial protocol. The other side, in input mode, listens to the voltages on the wire. One side sends a signal by outputting high and low voltage pulses on a wire that connects it to the other device. How do computers or integrated circuit components actually talk to each other? The (too-short) answer is that it’s almost exactly like what we were doing in Chapter 3. § (Optionally) an amplifier if you want to play it loud. § A speaker with a DC-blocking capacitor around 10 uF. In addition to the basic kit, you will need: Serial communication is the simplest possible way to interface your microcontroller with your desktop or laptop computer, your first step toward bridging the world of the physical and the virtual.
#Coolterm 104 framing error how to#
Before it’s all over, you’re going to have learned how to communicate between the AVR and your desktop or laptop computer and constructed a cheesy computer-controlled musical instrument.Īlong the way, you’re going to learn a little about serial communications protocols, and how you can generate quick-and-dirty audio with the AVRs. This chapter gives you a lot of bang for the buck.
