Delay (MPLAB sim)

Status
Not open for further replies.

Wavelength

New Member
Guys...I got this code from this web site **broken link removed**.
Anyway the problem is I just want to test it using MPLAB sim.During simulation run the green arrow will reach the "Loop1" then move to "goto" and back to "Loop1" only, it wont move on to other codes.Is there something wrong with the code or when I burn the program into the PIC will it act diffrently on practical run? Im trying to learn about creating a delay on a program.Thnx

STATUS equ 03h
TRISA equ 85h
PORTA equ 05h
COUNT1 equ 08h
COUNT2 equ 09h
bsf STATUS,5
movlw 00h
movwf TRISA
bcf STATUS,5
Start movlw 02h
movwf PORTA
call Delay
movlw 00h
movwf PORTA
call Delay
goto Start
Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
end
 
Assuming your using a 16F84 then, your variables are not in the correct area.

Try changing
COUNT1 equ 08h
COUNT2 equ 09h

To
COUNT1 equ 0Ch
COUNT2 equ 0Dh

If your using a 16F628 then move them to 20h and 21h.

Mike.
 
Wavelength said:
Hmm...still got the problem even tough I change the constant addresses .
hmm...u haven't inited the COUNT1 and COUNT2 variables.
try
Code:
 movlw 0xa
 movwf COUNT1

the loop u explained should 'loop' 10 times .
decfsz -> decr file skip if zero.
 
I manage to solve the problem by clicking the (Debugger>Clear Memory>All Memory).Don't know how this solve it though.After clicking that and without changing any code I manage to run the program smoothly without any problem in the MPLAB SIM.Sorry guys really appreaciate the help
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…