I'm writing a program that will blink red, yellow, and green LEDs off and on to match the function of a traffic light. However, when I run it in the debugger and step through (I am using MPLAB X IDE), it seems to stop after calling the function 'LOOP1'. The value reflected in PORTD is the value it should hold after completion of LOOP1, rather than after completion of LOOP6. Any ideas?
list p=18f4550, r=DEC
#include <p18f4550.inc>
CONFIG LVP=OFF
CONFIG WDT=OFF
CONFIG MCLRE=OFF
CONFIG FOSC = INTOSCIO_EC
ORG 0x00
CBLOCK 0
DELAY1:1
DELAY2:1
COUNTER:1
ENDC
START:
CLRF TRISD
CLRF PORTD
CLRF COUNTER
CLRF DELAY1
CLRF DELAY2
MOVLW 0x00
PRIMARYLOOP:
CALL LOOP1
CALL LOOP2
CALL LOOP3
CALL LOOP4
CALL LOOP5
CALL LOOP6
GOTO PRIMARYLOOP
LOOP1:
MOVLW b'00010010'
MOVWF PORTD
MOVLW 0x01
MOVWF COUNTER
CALL DELAYMAIN
RETURN
LOOP2:
MOVLW b'01000010'
MOVWF PORTD
MOVLW 0x05
MOVWF COUNTER
CALL DELAYMAIN
RETURN
LOOP3:
MOVLW b'00100010'
MOVWF PORTD
MOVLW 0x03
MOVWF COUNTER
CALL DELAYMAIN
RETURN
LOOP4:
MOVLW b'00010010'
MOVWF PORTD
MOVLW 0x01
MOVWF COUNTER
CALL DELAYMAIN
RETURN
LOOP5:
MOVLW b'01000010'
MOVWF PORTD
MOVLW 0x05
MOVWF COUNTER
CALL DELAYMAIN
RETURN
LOOP6:
MOVLW b'00100010'
MOVWF PORTD
MOVLW 0x03
MOVWF COUNTER
CALL DELAYMAIN
RETURN
DELAYMAIN:
DECFSZ DELAY1,1
GOTO DELAYMAIN
DECFSZ DELAY2,1
GOTO DELAYMAIN
DECFSZ COUNTER,0,0
RETURN
END