This is an old revision of the document!


Exercises

The goal is to write a program which is able to perform tasks described below.

Warm up exercise

  • Make the red LED blink. The period is 10 seconds (half period is 5 seconds). Create function of software delay, which's parameter is the amount of seconds.

For beginners

  1. Display the time on the LCD, with an accuracy of 100 ms, what is between pressings of random buttons. Execution of the time measurement is your own choice
  2. If the S1 button is pressed, the blinking speed of all three LED-s is slowed down three times. If the button S3 is pressed, the blinking gets 2 times faster. If S2 is pressed the frequency of the blinking will be 1 Hz. Use delay functions or interruptions (the interruptions are more difficult but when delay functions are used there will be an extra delay due to the filtering function of the buttons).
  3. Display the frequency of pressing down the button S1 on the 7 segment LED indicator in Hz-s. The display of the frequency must be limited with 0 at the bottom and with 9 at the top.
  4. If button S1 is pressed, the program reads the seconds from 60 to 0 and lights then the red LED. If button S2 is pressed the time is 30 seconds, after what the yellow LED is lit. S3 means that the time is 10 seconds and the LED is green. All the processes have to take place parallel. The LED-s are switching off when corresponding buttons are pressed.
  5. Display the Time on the LCD as follows: hh:mm:ss. Use hardware timer with one interruption and the Time must be configurable with the buttons. It is advised to use three buttons, of which the S1 steps rotationally up the hours, the S2 minutes and the S3 seconds.

For advanced

  1. Design a stopwatch, which’s LCD displays hours, minutes, seconds and milliseconds. The button S1 starts the time, the S2 stops it and S3 zeros it. Use interruption of the timer
  2. In 2 second intervals red, yellow and green LED-s are smoothly lit and switched off after each other. The smooth lighting is achieved by modulating the LED-s with hundredths of hertz (by lighting and switching it off very fast) and changing the proportions of lighted/switching off time. That is why it seems that for an eye it seems that the brightness of the LED-s is changing (we are dealing with the Pulse With Modulation here).
  3. Make a part of program in C-language which produces a delay of 10 μs ± 10 % at frequency of 14,7456 MHz. Prove the functioning of the delay theoretically - by commenting the instructions in assembler language in the .lss file of compiled program.

Kordamisküsimused

  1. Millised meetodid on viite tekitamiseks?
  2. Kuidas tekitada tarkvaraline viide? Millistest parameetritest tarkvaralise viite kestus sõltub?
  3. Mis sunnib kasutama raudvaralist taimerit koos katkestusega?
  4. Arvutage 8-bitise taimeri ületäitumise katkestuse periood, kui taktsagedus on 16 MHz ja sagedusjaguri tegur 1024.
  5. Mis asi on arvutites peituv “RTC”?
  6. Mis juhtub 19. jaanuaril 2038 arvutite maailmas?
  7. Mida saab AVR taimeritega veel teha peale aja loendamise?
  8. Milliste registritega saab seadistada ATmega128 taimer 0. Mida on nende registritega võimalik seadistada?
  9. Milline on suurim katkestuste ajaline täpsus millisekundites, mida on võimalik saavutada ATmega128 mikrokontrolleriga, mis töötab 14.7456 MHz taktsagedusel? Näidake arvutusvalem.
  10. Kui protsessor on tugevalt koormatud programmi täitmisega (näiteks juhib mitut mootorit ja kontrollib pidevalt paljude andurite väärtusi), siis kas see mõjutab taimeri aja mõõtmise täpsust? Selgitage oma vastust.
en/exercises/timer.1267726077.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0