hkBattousai
Advanced Member level 4
I'm trying to run a simple program which will flash a LED.
The code which runs without any problem is :
(The led connected at port D1 blinks)
And the erroneous code is :
(The led does not light)
Why doesn't my program work when I add a third delay variable?
MCU : PIC 18F4550
IDE : MPLAB 8.10
The code which runs without any problem is :
(The led connected at port D1 blinks)
Code:
org 0 ; Start code at 0
Delay1 res 1 ; Reserve 1 byte for the variable Delay1
Delay2 res 1 ; Reserve 1 byte for the variable Delay2
Start:
CLRF PORTD
CLRF TRISD
CLRF Delay1
CLRF Delay2
MainLoop:
BTG PORTD,RD1 ; Toggle PORT D PIN 1 (20)
Delay:
DECFSZ Delay1,1 ; Decrement Delay1 by 1, skip next instruction if Delay1 is 0
GOTO Delay
DECFSZ Delay2,1
GOTO Delay
GOTO MainLoop
end
And the erroneous code is :
(The led does not light)
Code:
org 0 ; Start code at 0
Delay1 res 1 ; Reserve 1 byte for the variable Delay1
Delay2 res 1 ; Reserve 1 byte for the variable Delay2
Delay3 res 1
Start:
CLRF PORTD
CLRF TRISD
CLRF Delay1
CLRF Delay2
CLRF Delay3
MainLoop:
BTG PORTD,RD1 ; Toggle PORT D PIN 1 (20)
Delay:
DECFSZ Delay1,1 ; Decrement Delay1 by 1, skip next instruction if Delay1 is 0
GOTO Delay
DECFSZ Delay2,1
GOTO Delay
DECFSZ Delay3,1
GOTO Delay
GOTO MainLoop
end
Why doesn't my program work when I add a third delay variable?
MCU : PIC 18F4550
IDE : MPLAB 8.10