Praktična naloga: utripanje LED diode na sistemu ARM FRI-SMS

Rok za oddajo: petek, 14. januar 2022, 23.55

1. Napišite program s programsko zanko, ki ima še eno vgnezdeno zanko. Notranja vgnezdena zanka naj se izvrši 48000-krat in v njej naj se 32-bitna vrednost v r1 vsakič poveča za 1. Zunanja zanka naj se izvede toliko krat, da bo vrednost v r1 na koncu programa enaka 24 000 000, če smo jo na začetku programa nastavili na 0.

2. Utripanje LED diode in/ali metronom z brenčačem na vgrajenem sistemu ARM FRI-SMS

Napišite program, ki bo na vgrajenem sistemu FRI-SMS prižigal in ugašal LED diodo (ali/in brenčača) na vsake pol sekunde. Glavni program, ki ga vstavite od mesta, označenega z "/* user code here*/" naprej, lahko opišemo s psevdo kodo takole :

VECNA: Vklop LED diode (in/ali brenčač)

                Počakaj 0.5 sekunde

                Izklop LED diode  (in/ali brenčač)

                Počakaj 0.5 sekunde

                Skoči na VECNA

»Vklop« in »izklop LED diode« dosežete z vpisom vrednosti 1 ali 0 v spremenljivko LED. »Vklop« in »izklop brenčača« pa dosežete z vpisom vrednosti 1 ali 0 v spremenljivko BUZZ. Po vsaki spremembi vrednosti je potrebno poklicati še podprogram z ukazom "bl WRITEOUT", ki poskrbi za prenos na dejanske nožice mikrokrmilnika. »Počakaj 0.5 sekunde« pa dosežete z izvedbo dvojne zanke iz naloge 2 – izpustite le povečevanje vrednosti v registru r1, ker ni več potrebno.

Opisano kodo dodate v sveže delovno okolje (»workspace«), ki ga restavrirate iz objavljenega projekta za FRI-SMS (ne tistega za simulator!) na e-učilnici. Ko boste to imeli narejeno, potem se na računalnik priključi vgrajen sistem FRI-SMS, se program prevede in se bo namesto v simulatorju izvajal na pravem vgrajenem sistemu – če je vse v redu bo utripala LED dioda in/ali se slišal brenčač s tiktakanjem podobno kot "metronom". Če ne deluje, poskusite z iskanjem napake ali pokličite na pomoč asistenta.

Praktični del (torej 2. naloga) je neobvezna, ampak upamo da zanimiva.

--------------------------------------------------------------------------------------------------------------------------------------

1. Write a program with an external loop that includes another inner (nested) loop. The internal nested loop should be executed 48 000 times and every time the 32-bit value in r1 should be incremented by 1. The external loop should be repeated so many times that the value at r1 at the end of the program (both loops) is equal to 24 000 000, if initial value was set to 0.

2. Flashing LEDs on the ARM FRI-SMS system

Write a program that will turn on and off the built-in orange LED on the FRI-SMS system every half a second. The main program that you insert from the place marked by "/ * user code here * /" can be described with a pseudo code as follows:

ENDLESS: Turn on the LED (and/or buzzer)

                Wait 0.5 second

                Turn off the LED  (and/or buzzer)

                Wait 0.5 second

                Goto ENDLESS

"Turning on" and "turning off" the LED is achieved by writing the values 1 or 0 in the predefined LED variable. "Turning on" and "turning off" the Buzzer is achieved by writing the values 1 or 0 in the predefined BUZZ variable. After each change of value, it is necessary to call a subroutine with the instruction "bl WRITEOUT", which transfers values to the actual pins of the microcontroller. "Wait 0.5 second" can be implemented by the nested loops from assignment 1 - you can omit the increase of the r1 register, because it is not needed.

Add the described code to a fresh workspace that you restore from the published project for FRI-SMS (not the one for the simulator used so far!) on the e-classroom. Once you have done this, then the FRI-SMS system is connected to the computer, the program is compiled and will be run instead in the simulator on the FRI-SMS system - if everything is ok, the LED will flash and buzzer will tick similarly to metronome. If it does not work, try to trace the error or contact the assistant.

The practical part (assignment 2) is optional, but hopefully interesting to complete.