Question : Problem: Delay loop

hello;
i have written a programme to turn on and off Four LEDs, i have given some delay loops but the LEDs are still on any they don't flash.  please take a look at my codes and let me know my problems. thankyou
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
status		equ 03h	; Status register address
trisA		equ 05h	; Sets direction of the I/O register (port A). This register is in memory bank 1
trisB		equ 06h	; Sets direction of the I/O register (port B). This register is in memory bank 1
port_A		equ 05h	; address of port A
port_B		equ 06h	; address of port B
count1		equ 08h
count2		equ 09h
 
pulse_on	equ 0ffh	; turn pulse on
pulse_off	equ 00h	; turn pulse off
rp0		equ 05h	; bit in status register to select register
				; bank 1 where trisA reg is stored
all_out		equ 00h	; sets all register bits as output
 
 
 
;*******************************************************************
		org 0h	; gives instruction to the assembly program to set the program at the first memory location
		goto main	; instructs the program to jump to the label "Main"
		org 010h	; gives instruction to the assembly program to set this line of the program 				;at memory address 0X10
main		bsf status, rp0	; sets the status register so that the program is 
				;looking a memory block 1 ( what does 0 mean) 
		movlw all_out	; moves the value of all_out to the working register
		movwf trisB	; puts the value from the working register to the special register trisA
		bcf status, rp0	; unsets the flag to the program is back looking at memory block 0
				; now port_c is set up as an out put port 
				; it has taken four lines of to initialise port_c
 
signal		movlw pulse_on	; Now the program can move the value pf Pulse_on to the working register
		movwf port_B		; it now moves the value in the working register to port_c
				; so the last two lines of code have out put the hex value of 0xff
 
;*****delay finished now turn the LED ff************
	movlw pulse_on
				movwf port_B
 
;****start delay loop******
Loop1	decfsz	count1,1 ;subtruct one from 255
		goto 	Loop1	  ;if count is ziro, carry on
		decfsz  count2,1 ;subtruct one from 255
	 	goto 	Loop1 		; go back to the start of our loop.
								;255 to ziro, 255 times
	
;*****delay finished now turn the LED off************
	movlw pulse_off
				movwf port_B
;*****adding another dylay************
Loop2   decfsz	count1,1  ;subtruct one from 255
		goto 	Loop2	  ;if count is ziro, carry on
		decfsz  count2,1 ;subtruct one from 255
	 	goto 	Loop2 		; go back to the start of our loop.
								;255 to ziro, 255 times
;*****delay finished now turn the LED ff************
	
 
		goto signal	; this line loops the program so it runs for ever
		end		; this is an instruction to the assembler to end the program
Open in New Window Select All

Answer : Problem: Delay loop

I don't know what chip you are using so I can't really tell you what they should be set to but

TRISA and PORTA should not have the same address
same goes for TRISB and PORTB
Random Solutions  
 
programming4us programming4us