ECE473 Lab3: Purpose: *Using interrupts with counter/timer 0 *Learn how to use SPI I/O. Overview: *This lab will extend upon the work done in lab 2. There are two things we are focusing on: interrupts and use of SPI. We will use interrupts to replace the loop+delay structure of last lab. Timer counter zero will be used to periodically interrupt the processor and obtain the state of the pushbutton switches and encoder. You will see that this is a much easier way to keep track of time-critical events. The SPI interface will be used to capture and then shift the state of the digital encoder serially to the uC while also providing data to the bar graph display. This can be done simultaneously. Project Specifications: *A quadrature encoder and bar graph diaplay will be constructed on a protoboard and be connected to the SPI interface. Circuitry for reading the encoder outputs using a parallel-in, serial-out shift register will also be implemented. *The buttons we used last time will be used again but in a different way. Before we incremented a count each time the button was pushed. Now we will have the switches to operate as "mode" switches. The mode selected will remain in effect until the next time the button is pushed. The encoder will be used to increment or decrement a count on the LED display. *Directly after reset, the encoder will increment or decrement, by one, a count displayed on the LED display. *One button (your choice) will choose a mode for incrementing or decrementing the count by two instead of one. *A second button (your choice) will choose a mode for incrementing or decrementing the count by four instead of one. *If both modes are selected, the count will not increment or decrement. *The count will roll over at 1023 as before but if decremented beyond zero, the next count will be 1023. *Use the bar graph display to graphically show how large the count is by use of a thermometer code. For example, for increasing values, for every 32 steps upwards, the bar graph will illuminate one bar. The same behavior will follow for decrementing values. Also, use LED segment "L3" to indicate the count mode as up or down. Before Lab: *Determine the correct connection for the SPI interface for reading the encoder and displaying to the bar graph. You will need to become familiar with the operation of both the 74HC165 and 74HC595 to use them correctly. Draw that part of your schematic out _before_ you wire things up. *74HC165 shift/load_n should be connected to PORTE bit 6. *Use PORTD bit 2 for the HC595 output register clock pulse. Software: *Write out pseudocode of your software (suggested). *Suggested 8-bit timer/counter 0 (TCNT0) initialization code is shown below: //timer counter 0 setup, running off i/o clock TIMSK |= (1<