Professional Documents
Culture Documents
Lab 6
Lab 6
(Lab 6 Report)
Abdullah Bilgin
181110017
Instructors
Prof. Dr. HASAN ŞAKİR BİLGE
Arş. Gör. ORHAN BARIŞ GANGAL
İNİTİALİZE SECTİON:
gpioData EQU 0x000 ; 'data' add relevant gpio data mask offset for masking, to
read or write all values add 0x3FC to base which is sum of all bit constants
gpioDir EQU 0x400 ; 'direction' 0 for inp, 1 for out, inp by default
gpioAfsel EQU 0x420 ; 'alterrnate function select' 0 for standard gpio and gpio
register used in this time, 1 for path over selected alternate hardware function, hardware function
selection is done by gpiopctl register control, 0 default
gpioLock EQU 0x520 ; to unlock 0x4c4f434b shoulb be written, any other write
locks back, enables write access to gpiocr
gpioCr EQU 0x524 ; 'commit' gpioafsel, pur, pdr, den can only be changed with
setting bit in cr, only modified when unlock gpiolock
gpioAmsel EQU 0x528 ; 'analog mode select' only valid for pins of adc, set for
analog,
; 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
gpioIs EQU 0x404 ; 'interrupt sense' 1 for level sensitivity, 0 for edge sensitivity,
default 0 all
gpioIev EQU 0x40C ; 'interrupt evet' 1 for rising edge, 0 for falling edge, 0 default
gpioRis EQU 0x414 ; 'raw interrupt status' read only, set automatically if
interrupt occur if gpioim is set interrupt sent is to interrupt controller, if level detectin signal must be
held until serviced, if edge write 1 to gpioicr to erase relavent gpioris, gpiomis is the masked value of
gpioris
gpioIcr EQU 0x41C ; 'interrupt clear' for edge sensitivity write 1 clears gpiomis
and gpioris, no effect on level detect, no effect writing 0
gpioDr2r EQU 0x500 ; '2ma drive select' if select dr4r, dr8r cleared automatically,
all set default
gpioOdr EQU 0x50C ; 'open drain select' set for open drain, if set
corresponding gpioden bit should also be set, gpiodr2r, 4r,8r, gpioslr should be used for desired fall
time, if pin is imput no effect
gpioPur EQU 0x510 ; 'pullup select' set to add 20k ohm pullup, if set gpiopdr
automatically cleared, write access protected by gpiocr register
gpioSlr EQU 0x518 ; 'slew rate sontrol select' available only when 8ma strength
used
; bit #0 for port A and #1 for port B should be set to enable ports
EXPORT initializegpio
initializegpio
NOP
NOP
NOP
; afsel E Base
LDR R0,[R1]
LDR R0,[R1]
LDR R1,=gpioDbase
ADD R1,#gpioIm
LDR R0,[R1]
ORR R0,#2
STR R0,[R1]
LDR R1,=gpioDbase
ADD R1,#gpioIbe
LDR R0,[R1]
ORR R0,#2
STR R0,[R1]
LDR R1,=nvicBase
ADD r1,#nvicEN0
LDR R0,[R1]
ORR R0,R0,#0x8
STR R0,[R1]
BX LR
ALIGN
END
gpioData EQU 0x000 ; 'data' add relevant gpio data mask offset for masking, to
read or write all values add 0x3FC to base which is sum of all bit constants
gpioDir EQU 0x400 ; 'direction' 0 for inp, 1 for out, inp by default
gpioAfsel EQU 0x420 ; 'alterrnate function select' 0 for standard gpio and gpio
register used in this time, 1 for path over selected alternate hardware function, hardware function
selection is done by gpiopctl register control, 0 default
gpioCr EQU 0x524 ; 'commit' gpioafsel, pur, pdr, den can only be changed with
setting bit in cr, only modified when unlock gpiolock
gpioAmsel EQU 0x528 ; 'analog mode select' only valid for pins of adc, set for
analog,
; 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
; NVIC (ENn) nested vectored interrupt controller- interrupt set enable registers activate to handle
exceptions of relavent sources
gpioIs EQU 0x404 ; 'interrupt sense' 1 for level sensitivity, 0 for edge sensitivity,
default 0 all
gpioIbe EQU 0x408 ; 'interrupt both edges' if 1 regardless of gpioie register
interrupt occur for both edge, if 0 gpioie register define which edge, default 0 all
gpioIev EQU 0x40C ; 'interrupt evet' 1 for rising edge, 0 for falling edge, 0 default
gpioRis EQU 0x414 ; 'raw interrupt status' read only, set automatically if
interrupt occur if gpioim is set interrupt sent is to interrupt controller, if level detectin signal must be
held until serviced, if edge write 1 to gpioicr to erase relavent gpioris, gpiomis is the masked value of
gpioris
gpioIcr EQU 0x41C ; 'interrupt clear' for edge sensitivity write 1 clears gpiomis
and gpioris, no effect on level detect, no effect writing 0
gpioDr2r EQU 0x500 ; '2ma drive select' if select dr4r, dr8r cleared automatically,
all set default
gpioOdr EQU 0x50C ; 'open drain select' set for open drain, if set
corresponding gpioden bit should also be set, gpiodr2r, 4r,8r, gpioslr should be used for desired fall
time, if pin is imput no effect
gpioPur EQU 0x510 ; 'pullup select' set to add 20k ohm pullup, if set gpiopdr
automatically cleared, write access protected by gpiocr register
gpioSlr EQU 0x518 ; 'slew rate sontrol select' available only when 8ma strength
used
; bit #0 for port A and #1 for port B should be set to enable ports
ALIGN
EXTERN checkblink
EXPORT ISRD
ISRD PROC
PUSH {LR}
BL checkblink
POP {LR}
ADD R1,#gpioIcr
LDR R0,[R1]
ORR R0,#2
STR R0,[R1]
BX LR
ENDP
ALIGN
ALIGN
EXTERN initializegpio
ENTRY
EXPORT __main
__main
BL initializegpio
bbb B bbb
ALIGN
END
MAİN
gpioData EQU 0x000 ; 'data' add relevant gpio data mask offset for masking, to
read or write all values add 0x3FC to base which is sum of all bit constants
gpioDir EQU 0x400 ; 'direction' 0 for inp, 1 for out, inp by default
gpioAfsel EQU 0x420 ; 'alterrnate function select' 0 for standard gpio and gpio
register used in this time, 1 for path over selected alternate hardware function, hardware function
selection is done by gpiopctl register control, 0 default
gpioLock EQU 0x520 ; to unlock 0x4c4f434b shoulb be written, any other write
locks back, enables write access to gpiocr
gpioCr EQU 0x524 ; 'commit' gpioafsel, pur, pdr, den can only be changed with
setting bit in cr, only modified when unlock gpiolock
gpioAmsel EQU 0x528 ; 'analog mode select' only valid for pins of adc, set for
analog,
; 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
; NVIC (ENn) nested vectored interrupt controller- interrupt set enable registers activate to handle
exceptions of relavent sources
gpioIs EQU 0x404 ; 'interrupt sense' 1 for level sensitivity, 0 for edge sensitivity,
default 0 all
gpioIev EQU 0x40C ; 'interrupt evet' 1 for rising edge, 0 for falling edge, 0 default
gpioRis EQU 0x414 ; 'raw interrupt status' read only, set automatically if
interrupt occur if gpioim is set interrupt sent is to interrupt controller, if level detectin signal must be
held until serviced, if edge write 1 to gpioicr to erase relavent gpioris, gpiomis is the masked value of
gpioris
gpioMis EQU 0x418 ; 'masked interrupt status' readonly, if 1 sent to
interrupt controller, if 0 no interrupt or masked
gpioIcr EQU 0x41C ; 'interrupt clear' for edge sensitivity write 1 clears gpiomis
and gpioris, no effect on level detect, no effect writing 0
gpioDr2r EQU 0x500 ; '2ma drive select' if select dr4r, dr8r cleared automatically,
all set default
gpioOdr EQU 0x50C ; 'open drain select' set for open drain, if set
corresponding gpioden bit should also be set, gpiodr2r, 4r,8r, gpioslr should be used for desired fall
time, if pin is imput no effect
gpioPur EQU 0x510 ; 'pullup select' set to add 20k ohm pullup, if set gpiopdr
automatically cleared, write access protected by gpiocr register
gpioSlr EQU 0x518 ; 'slew rate sontrol select' available only when 8ma strength
used
; bit #0 for port A and #1 for port B should be set to enable ports
ALIGN
EXTERN checkblink
EXPORT ISRD
ISRD PROC
PUSH {LR}
BL checkblink
POP {LR}
ADD R1,#gpioIcr
LDR R0,[R1]
ORR R0,#2
STR R0,[R1]
BX LR
ENDP
ALIGN
ALIGN
EXTERN initializegpio
ENTRY
EXPORT __main
__main
BL initializegpio
bbb B bbb
ALIGN
END
BLİNKS
gpioData EQU 0x000 ; 'data' add relevant gpio data mask offset for masking, to
read or write all values add 0x3FC to base which is sum of all bit constants
gpioDir EQU 0x400 ; 'direction' 0 for inp, 1 for out, inp by default
gpioAfsel EQU 0x420 ; 'alterrnate function select' 0 for standard gpio and gpio
register used in this time, 1 for path over selected alternate hardware function, hardware function
selection is done by gpiopctl register control, 0 default
gpioLock EQU 0x520 ; to unlock 0x4c4f434b shoulb be written, any other write
locks back, enables write access to gpiocr
gpioCr EQU 0x524 ; 'commit' gpioafsel, pur, pdr, den can only be changed with
setting bit in cr, only modified when unlock gpiolock
gpioAmsel EQU 0x528 ; 'analog mode select' only valid for pins of adc, set for
analog,
; 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
gpioIs EQU 0x404 ; 'interrupt sense' 1 for level sensitivity, 0 for edge sensitivity
gpioIev EQU 0x40C ; 'interrupt evet' 1 for rising edge, 0 for falling edge, 0 default
gpioRis EQU 0x414 ; 'raw interrupt status' read only, set automatically if
interrupt occur if gpioim is set interrupt sent is to interrupt controller, if level detectin signal must be
held until serviced, if edge write 1 to gpioicr to erase relavent gpioris, gpiomis is the masked value of
gpioris
gpioIcr EQU 0x41C ; 'interrupt clear' for edge sensitivity write 1 clears gpiomis
and gpioris, no effect on level detect, no effect writing 0
gpioDr2r EQU 0x500 ; '2ma drive select' if select dr4r, dr8r cleared automatically,
all set default
gpioOdr EQU 0x50C ; 'open drain select' set for open drain, if set
corresponding gpioden bit should also be set, gpiodr2r, 4r,8r, gpioslr should be used for desired fall
time, if pin is imput no effect
gpioPur EQU 0x510 ; 'pullup select' set to add 20k ohm pullup, if set gpiopdr
automatically cleared, write access protected by gpiocr register
gpioSlr EQU 0x518 ; 'slew rate sontrol select' available only when 8ma strength
used
; GPIO clck gating register
; bit #0 for port A and #1 for port B should be set to enable ports
ALIGN
EXPORT checkblink
checkblink
PUSH {LR}
; check sw
LDR R2,=1
blink
LDR R1,=gpioEbase
ADD R1,#0x04
LDR R0,[R1]
ORR R0,#0x01
STR R0,[R1]
BL delay
AND R0,#0x0
STR R0,[R1]
BL delay
SUBS R2,#1
BNE blink
POP {LR}
BX LR
delay
wait
SUBS R8, #1
BNE wait
BX LR
ALIGN
END