Essentially, what I'm trying to do is have lights cycle through 3 corresponding LEDs on the breadboard via some ARM assembly code on the KL25Z using Keil uVision 5 as my IDE. I've chosen PIN PTA2 to be my green LED, PTA4 to be my yellow, PTA5 to be my red, PCR7 to be emergency reset button which restarts the cycle at green (I haven't implemented this in code yet since I haven't even gotten the cycle to work) -- details are commented in the code. No LEDs are being lit up and I'm curious as to why. Here is my code:
SIM_SCGC5 EQU 0x40048038 ;SIM_SCGC5 address
SIM_COPC EQU 0x40048100 ;SIM_COPC (watchdog) address
PORTA_PCR2 EQU 0x40049008 ;PORTA_PCR2 (PTA2) address
PORTA_PCR4 EQU 0x40049010 ;PORTA_PCR4 (PTA4) address
PORTA_PCR5 EQU 0x40049014 ;PORTA_PCR5 (PTA5) address
PORTC_PCR7 EQU 0x4004B01C ;PORTA_PCR7 (PTC7) address
PORTA_PDDR EQU 0x400FF014
PORTA_PDOR EQU 0x400FF000
PORTC_PDDR EQU 0x400FF094
PORTC_PDIR EQU 0x400FF090
GREEN_MASK EQU 0x00000004 ; PORTA_PIN 2
YELLOW_MASK EQU 0x00000010 ; PORTA_PIN 4
RED_MASK EQU 0x00000020 ; PORTA_PIN 5
INIT_MASKS EQU 0x00000034 ; PORTA_PIN 2, 4 and 5
BUTTON_MASK EQU 0X00000080 ; PORTC_PIN 7
DELAY_CNT EQU 0X00800000
AREA asm_area, CODE, READONLY
EXPORT asm_main
asm_main ;assembly entry point for C function, do not delete
; Add program code here
BL init_gpio
loop
BL greenon
LDR R0, =DELAY_CNT
BL delay
BL redon
LDR R0, =DELAY_CNT
BL delay
BL yellowon
LDR R0, =DELAY_CNT
BL delay
B loop
greenon
LDR R0,=PORTA_PDOR ;Load address of PORTA_PDOR to R0
LDR R1,=GREEN_MASK ;Load value to R1
STR R1,[R0] ;Put value into PORTA_PDOR
BX LR
redon
LDR R0,=PORTA_PDOR ;Load address of PORTA_PDOR to R0
LDR R1,=RED_MASK ;Load value to R1
STR R1,[R0] ;Put value into PORTA_PDOR
BX LR
yellowon
LDR R0,=PORTA_PDOR ;Load address of PORTA_PDOR to R0
LDR R1,=YELLOW_MASK ;Load value to R1
STR R1,[R0] ;Put value into PORTA_PDOR
BX LR
delay
SUBS R0, #10
BNE delay
BX LR
init_gpio
;Disable watchdog timer (COP)
LDR R0,=SIM_COPC
LDR R1,=0x0
STR R1,[R0]
;Turns on clocks for all ports
LDR R0,=SIM_SCGC5 ;Load address of SIM_SCGC5 to R0
LDR R1,[R0] ;Get original value of SIM_SCGC5
LDR R2,=0x00003E00 ;Load mask for bits to set to R2
ORRS R1,R2 ;Set bits with OR of orig val and mask
STR R1,[R0] ;Put new value back into SIM_SCGC5
; Setup PORTA Pins 2,4 and 5 to be outputs
LDR R0,=PORTA_PDDR ;Load address of PORTA_PDDR to R0
LDR R1,=INIT_MASKS ;Load new value to R1
STR R1,[R0] ;Put value into PORTA_PDDR
; Setup PORTC Pin 7 to be an input
LDR R0,=PORTC_PDDR ; Load address of PORTC_PDDR to R0
LDR R1,=BUTTON_MASK ;Load new value to R1
STR R1,[R0] ;Put value into PORTC_PDDR
BX LR
END