Hello,
I am an engineering student doing my Introductory to Assembly course and I am having a play (outside the scope of the subject) with the SW1 and SW2 on the TM4C123GXL. I am trying to use the onboard switches to cause an interrupt.
Whenever I press either switch the tiva freezes, I can see the GPIO data light up and the RIS register goes high but no interrupt. I added a milestone to my routine and it never reaches it but the main.s routine runs fine. The interrupt does not need to be in the vectors to cause the freeze. I am using keil uvision5.
I was hoping the problem has something to do with the inputs on port F that I have not been taught. Please no C.
parts of my setup are below;
Setup_GPIOF ;Port F0, F4
PUSH {LR, R0-R2}
LDR R0, =SYSCTL_BASE ; Setup Port F
MOV R2, #0x20
LDR R1, [R0, #RCGCGPIO]
ORR R1, R2 ; enable CLOCK
STR R1, [R0, #RCGCGPIO]
Wait_F LDR R1, [R0, #PRGPIO] ; wait for port to ACTIVATE
AND R1, R2 ; clear all but 1 bit
CMP R1, R2 ; call individual bit
BNE Wait_F
LDR R0, =GPIO_F_BASE
LDR R1, =UNLOCK
STR R1, [R0, #GPIO_LOCK]
MOV R1, #0xFF
STR R1, [R0, #GPIO_CR] ;UNLOCK SW2 (PORTF0)
MOV R2, #0x1F
LDR R1, [R0, #GPIO_DIR] ; set port a DIRECTION
BIC R1, #0x11 ; INPUT
ORR R1, #0xE ; OUTPUT
STR R1, [R0, #GPIO_DIR]
LDR R1, [R0, #GPIO_AFSEL] ; set port a FUNCTION (REGULAR)
BIC R1, R2
STR R1, [R0, #GPIO_AFSEL]
LDR R1, [R0, #GPIO_DR2R] ; set port a 2mA DRIVE
ORR R1, #0xE
STR R1, [R0, #GPIO_DR2R]
LDR R1, [R0, #GPIO_PCTL] ; set port a 2mA DRIVE
ORR R1, #0x8
LDR R1, [R0, #GPIO_DEN] ; set port a DIGITAL
ORR R1, R2
STR R1, [R0, #GPIO_DEN]
LDR R1, [R0, #GPIO_PUR]
ORR R1, #0x11
STR R1, [R0, #GPIO_PUR] ;PULL UP RESISTOR
MOV R1, #0x0
STR R1, [R0, #GPIO_LOCK] ;LOCK PF0
POP {LR, R0-R2}
BX LR
SetupF_Interrupts
PUSH {LR, R0-R2}
; BL Inter_SetupD
CPSID i
BL Setup_GPIOF
LDR R0, =GPIO_F_BASE
MOV R2, #0x11 ;PINS 0 and 4
LDR R1, [R0, #GPIO_IM]
BIC R1, #0x1F ;DISABLE
STR R1, [R0, #GPIO_IM]
LDR R1, [R0, #GPIO_IS]
BIC R1, R2 ;EDGE
STR R1, [R0, #GPIO_IS]
LDR R1, [R0, #GPIO_IBE]
BIC R1, R2 ;SINGLE
STR R1, [R0, #GPIO_IBE]
LDR R1, [R0, #GPIO_IEV]
BIC R1, R2 ;FALLING
STR R1, [R0, #GPIO_IEV]
LDR R1, [R0, #GPIO_IM]
ORR R1, #0x10 ;ENABLE
STR R1, [R0, #GPIO_IM]
LDR R0, =NVIC_BASE
LDR R1, [R0, #NVIC_EN0]
ORR R1, #(0x1<<30) ;PORT F
STR R1, [R0, #NVIC_EN0]
LDR R1, [R0, #NVIC_PRI7]
ORR R1, #(0x1<<21) ;PRI 1 #0x2000
BIC R1, #(0x6<<21) ; #0xC000
STR R1, [R0, #NVIC_PRI7]
LDR R0, =GPIO_F_BASE
LDR R1, [R0, #GPIO_ICR]
ORR R1, #0x1F ;clear interrupt
STR R1, [R0, #GPIO_ICR]
CPSIE i
POP {LR, R0-R2}
BX LR
CYCLE LDR R0, =GPIO_F_BASE ; main.s loop
RED MOV R2, #0x2
STR R2, [R0, #0x3FC] ;TURN ON LEDS RED
MOV R4, #333
BL DelayMs
BLUE MOV R2, #0x4
STR R2, [R0, #0x3FC] ;TURN ON LEDS BLUE
MOV R4, #333
BL DelayMs
GREEN MOV R2, #0x8
STR R2, [R0, #0x3FC] ;TURN ON LEDS GREEN
MOV R4, #333
BL DelayMs
B CYCLE
Thanks in advance,
Greg.