Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top