- Introduce UART (Universal Asynchronous Receiver Transmitter)
- Interface PC with AVR Butterfly via UART
- Implement UART communications using AVR Assembly
Install the appropriate program on your computer
- Windows
- RealTerm (preferred)
- Putty
- Linux/Mac
- minicom
- Ubuntu:
sudo apt install minicom
- COM or serial port uses as few as 3 wires,
GND
, RX
and TX
(named with respect to the master)
- Slave Device (TX) -> Master Device (RX)
- Slave Device (RX) <- Master Device (TX)
- Data is transmitted without a clock and is instead transmitted at a rate predetermined or pre-negotiated rate known on both sides
- The baud rate defines the length of each bit as buadrate1
- data is framed by a start bit and one or more stop bits
- start bit is typically a high signal to start the data frame
- stop bit is typically a low signal, often 1, 1.5 or 2 times as long as the other bits
- serves as pause between the frames, allowing the next start bit
- Typically, a FIFO buffer of 1 or more bytes is used for transmission and reception
- The status of the buffers is probed internally by empty and possibly full status bits
- If the read buffer is only 1 byte, NOT EMPTY is the same as DATA READY
- If the write buffer is only 1 byte, NOT EMPTY is the same as NOT READY/FULL
Handling Buffer Overflow
- What happens if the Master sends data to the slave receive buffer faster than it can be unloaded ?
- To prevent overflow, additional hardware lines can be used to communicate status and perform handshaking
- A software handshaking can also be implemented
- The configuration for stop/start bits, parity, hardware/software hand shaking, and baud rate must be set the same on both ends of the communication
- The following set of registers are used to communicate over UART
- UCSRA
- Flags for various errors that might occur during data transmission, e.g. parity error, frame error etc.
- UCSRB
- Contains lot of enable bits. eg. different interrupt enable bits and the receiving and transmitting enable bits
- UCSRC
- Set the parity mode, stop bits etc.
- UBRRH & UBRRL
- The higher byte (UBRRH) and lower byte (UBRRL) is stored for generating the required baud rate
- For Our AVR, the required registers have slightly different names and are in the EXTENDED I/O, meaning, we must access them as memory and not as registers
Realterm
- Select the correct port, Baud(rate), #Stop Bits
- Use the Open and/Change buttons to update settings
- Status in displayed in the Bottom-Right Status Bar
- Initially it will read "Closed"
- Make sure that any changes are displayed
Download interfacing code from your instructor’s website (uart.s)