Lecture 14: Computer Peripherals The last homework and lab for the course will involve using programmable logic to make interesting things happen on a computer monitor should be even more fun than the 7-segment LED! For this to work, we need to know exactly what signals the monitor expects, and when it expects them this is called the communication protocol for any device interfaced to a computer Historically, there have been many protocols for monitors a new one is needed whenever higher resolution becomes available The one we ll discuss is called VGA not the latest (introduced in 1987), but still pretty decent resolution -- 640 (horiz.) x 480 (vert.) pixels newer protocols tend to be specific to manufacturer
The VGA monitor requires 5 input signals two synchronization (sync) signals for horizontal and vertical three color signals, (red, green, and blue) these are actually analog signals, ranging from 0.7 to 1.0 V voltage level corresponds to brightness of each color in this way, thousands of possible colors can be generated in our lab, we ll pretend these are digital i.e., each of the three colors can be on or off means we ll only have 8 possible colors
Overview of monitor operation Pixels are drawn one at a time Starts in upper left corner then fills in all the pixel on the top line of the screen moves to next line down fills in all the pixels on that line and so on until the entire screen is drawn then it starts again in the upper left corner, and refreshes the screen Why do we perceive the entire screen as illuminated? in CRT, the phosphors continue to glow for a while after being drawn in LCD, the pixels hold their value until being redrawn
Sync signals The sync signals need to be timed properly for the monitor to function Vertical sync: tells monitor to start at upper left corner of screen period of this signal is the refresh period for the screen in standard VGA, this is 16.6 ms 60Hz refresh rate this is near the upper limit of what human eye can perceive can see flicker on a bright screen, especially from the corner of your eye newer monitors run at up to 85 Hz flicker is not noticeable at this speed
Vertical sync details: signal at GND means start display refresh sequence signal remains at GND for 64µs (the sync pulse) drawing of pixels starts 1.02ms after sync pulse drawing of pixels ends 0.35ms before next sync pulse Summary: Sync pulse Video data
Horizontal sync details: goes to GND for 3.77µs video data starts 1.89µs after sync pulse ends video data sent for 25.17µs video data ends 0.94µs before next sync pulse Note that this means 640 pixels are drawn in 25.17µs requires clock rate of 25MHz that s why the clock on the Altera boards has this frequency! Summary: Sync pulse Video data
Code for generating the proper sync signals is available on the course website this code will also output counters telling you what pixel (row and column number) is currently being drawn
Keyboard We won t be using a keyboard in the lab, so this is just for your information and so 505 students can feel free to include one in their final projects! The keyboard communicates over a serial link Total of five wires connect keyboard to PC power ground clock data reset The clock is generated by the keyboard (not the computer) much slower than CPU clock (10 20 khz)
The data line is bidirectional usually the keyboard is sending data to the computer but the computer can send information as well e.g. to tell the keyboard to turn on an LED when CAPS LOCK is enabled Data line is held at 1 when no data is being sent When a key is pressed, 11 bits are sent on the data line serial, so one bit per clock cycle First is a start bit (always 0) this tells the computer that the keyboard will be sending data Next 8 bits are the make code for the key that was pressed
10 th bit is a parity bit this bit is set to 1 if an even number of bits are set to 1 in the make code, and 0 otherwise this ensures that the total number of bits set to 1 is odd the computer can use this to check for errors in the data sent by the keyboard and request that the data be resent if necessary When a key is released, the keyboard sends a break code In the same format as the make code, but uses two sets of 11 bits in the first set, the 8-bit data is 11110000 (F0) in the second set, it s the make code for the key that was released This protocol allows the computer to understand that the SHIFT key is still being held down when the next key is pressed, for example
Keyboard control codes A complete list of the control codes sent between the PC and keyboard (in hexidecimal format): Control codes send from PC to keyboard:
Control codes sent from keyboard to PC: Make and break codes: