LAB4İSTENEN
LAB4İSTENEN
; GPIO data mask offset constant, [9:2] in address are ussed for [7:0] bits masking
; to only write to pin 5 of any port 'five' offset should be added to gpiodata
; to only write to pins 2 and 5 of any port data should be written dataregister
address + 'two'+'five' offset address remainings left unchange in output 0 in input
mode
gpioDataZero EQU 0x004
gpioDataOne EQU 0x008
gpioDataTwo EQU 0x010
gpioDataThree EQU 0x020
gpioDataFour EQU 0x040
gpioDataFive EQU 0x080
gpioDataSix EQU 0x100
gpioDataSeven EQU 0x200
; Start of __main
AREA MYCODE, CODE
ALIGN
ENTRY
EXPORT __main
__main
NOP
BL initializegpio ; porte is adjusted as
output and portd as input use porte bit 0 and 1 and portd bit 0 for this experiment
for the following code blocks
LDR R4 , =time1
LDR R5 , =time2
checkSwitch
SUB R4, R4 ,#1
CMP R4, #0
LDREQ R4 , =time1
CMP r4,r5
BLE lowFreq ; Branch to slowBlink if
switch is off
BGT highFreq ; Branch to
fastBlink if switch is on
initializegpio
; enable clck for ports D and E
LDR R1, =rcgcgpio
LDR R0, [R1]
ORR R0, R0, #0x09
STR R0, [R1]
NOP
NOP
NOP
; out port E
LDR R1, =gpioAbase
ADD R1, R1, #gpioDir
LDR R0, [R1]
ORR R0, R0, #0xFF
STR R0, [R1]
; afsel
LDR R1, =gpioAbase
ADD R1, R1, #gpioAfsel
LDR R0, [R1]
BIC R0, #0xFF
STR R0, [R1]
LDR R1, =gpioDbase
ADD R1, R1, #gpioAfsel
LDR R0, [R1]
BIC R0, #0xFF
STR R0, [R1]
; den 1 for ports
LDR R1, =gpioDbase
ADD R1, R1, #gpioDen
LDR R0,[R1]
ORR R0, R0, #0xFF
STR R0, [R1]
LDR R1, =gpioAbase
ADD R1, R1, #gpioDen
LDR R0,[R1]
ORR R0, R0, #0xFF
STR R0, [R1]
BX LR
ALIGN
END