The ‘delay’ function as used in the workshops is limited because it depends on approximate timing based on how long the processortakes to execute the ‘NOP’ instruction, and the limitations ofthe size of an integer means that the maximum delay will be approximately 65 seconds. Furthermore, the processor cannot do anything else while the delay is going on, and any interrupts run during the ‘delay’ will cause the delay to be longerthan
The Atmel ATmega168 does provide the facility to maintain more accurate and longer
timings through the use ofthe crystaloscillator and the timer/counter circuitry in the
processor.Yourtask is to work out howto use these components so that programs can be
written to accurately trigger events at least up to 1 hour after a ‘timer’ is ‘set’. The function should allow
forthe timer interval to be set in minutes and seconds.
Your solution should include the following:
1. Overall description ofthe principles of operation of your solution
2. Description of all timer/counters, registers, and interrupts used and theirfunction
3. Details of all configuration information to get the processorto perform this function
(e.g. what needs to be written to different configuration registers, including
WHY particular bits are set or cleared)
4. Description ofthe overall algorithm(s) to implement the function
Note: This can be in the form of pseudocode. Code fragments (lines of code) can be
used to demonstrate where appropriate.
Note: You do NOT have to write the whole program
Task 2: Interfacing a 7-segment LED display (20 marks)
7-segment LED displays are commonly used in microcontroller
applications. The datasheet forthe Avago HDSP-5601 LED display is attached. Yourtask is to ‘design’ an interface
between the Atmel ATmega168 microcontroller and this particular display.
1. Referto the datasheet, pick out all the relevant interface data (this is a very
important practical skill!) and clearly list them. Note: Make sure you get details ofthe right model.
2. Produce a circuit diagram with details of all elements required to allowthe processor
to drive this particular LED display properly. You should provide copies of the datasheets for any elements you may choose to include in your design (except passive elements such as resistors and capacitors).
3.Describe how your circuit elements address the interfacing requirements. ensure that you consider both the Atmega168 and LED display requirements specifications, and justify any decisions made, including any calculations if required.
4. Write a C subroutine that will enable the display ofthe digits ‘0’ to ‘9’ and characters a’ to ‘f’ (for hex numbers) on the LED display (specified by a parameter passed to the subroutine). Note: Assume you are using the NerdKit as in the labs.