Praktična naloga: utripanje LED diode na sistemu ARM FRI-SMS (kopiraj)
1. Napišite program s programsko zanko, ki ima še eno vgnezdeno zanko. Notranja vgnezdena zanka naj se izvrši 64000-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 32 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 STM32H7
Napišite program, ki bo na vgrajenem sistemu STM32H7 prižigal in ugašal LED diodi (ali/in brenčača) na vsake pol sekunde. Glavni program lahko opišemo s psevdo kodo takole :
VECNA: Vklop LED diod (in/ali brenčač)
Počakaj 0.5 sekunde
Izklop LED diod (in/ali brenčač)
Počakaj 0.5 sekunde
Skoči na VECNA
»Vklop« in »izklop LED diod« dosežete z vpisom vrednosti 1 ali 0 v spremenljivki LED1 in LED2. »Vklop« in »izklop brenčača« pa dosežete z vpisom vrednosti 1 ali 0 v spremenljivko PA3. 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ži projekt, ki ga prekopirate iz Github repozitorija - URL na e-učilnici. Ko boste to imeli narejeno, potem se na računalnik priključi vgrajen sistem STM32H7, 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) zanimiva.
--------------------------------------------------------------------------------------------------------------------------------------
1. Write a program with an external loop that includes another inner (nested) loop. The internal nested loop should be executed 64 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 32 000 000, if initial value was set to 0.
2. Flashing LEDs on the STM32H7 system
Write a program that will turn on and off the built-in red and green LEDs on the STM32H7 system every half a second. The main program can be described with a pseudo code as follows:
ENDLESS: Turn on the LEDs (and/or buzzer)
Wait 0.5 second
Turn off the LEDs (and/or buzzer)
Wait 0.5 second
Goto ENDLESS
"Turning on" and "turning off" the LEDs is achieved by writing the values 1 or 0 in the predefined LED1 and LED2 variables. "Turning on" and "turning off" the Buzzer is achieved by writing the values 1 or 0 in the predefined PA3 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 anymore.
Add the described code to a project that you copy from the Github repository (link on the e-classroom). Once you have done this, then the STM32H7 system is connected to the computer, the program is compiled and will be run instead in the simulator on the STM32H7 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.