Flash1 - Output and nested time delay


The main program can be broken up into three main areas:

;**************************************************************************
;
; This Program developed by Peter Hayles for PIC 16C711
;
; Flashes the LEDs on B1 and B2.
; The LEDs should be connected from B1 and B2 to ground
; with a 100 ohm resistor in series .
;
;**************************************************************************

#include 	"p16c711.inc"
        	LIST P=16C711

;--------------------------------------------------------------------------
; Variables
;--------------------------------------------------------------------------

RAM		EQU	0x30	

Portin		EQU     RAM+0
Loop1       	EQU    	RAM+1
Loop2	      	EQU    	RAM+2
Loop		EQU  	RAM+3


;--------------------------------------------------------------------------
; Program Code
;--------------------------------------------------------------------------

            	ORG     0       
            	GOTO   	Start

;--------------------------------------------------------------------------
; Main Program
;--------------------------------------------------------------------------

            	ORG     H'05'

Start
		BCF	STATUS,RP0	;Clear Data Bus
		CLRF	PORTB
		CLRF	PORTA		
		BSF	STATUS,RP0	;Set Port B 0=Input & 1-7=Output
		MOVLW	B'00000001'	
		MOVWF	TRISB		
		BCF	STATUS,RP0	;Clear Data Bus

Again		
		
		MOVLW	B'00000110'	;Set Outputs to HI, HI
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000100'	;Set Outputs to HI, LO
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000010'	;Set Outputs to LO, HI
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000100'	;Set Outputs to HI, LO
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000010'	;Set Outputs to LO, HI
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000100'	;Set Outputs to HI, LO
		MOVWF	PORTB
		Call	Delay

		MOVLW	B'00000010'	;Set Outputs to LO, HI
		MOVWF	PORTB
		Call	Delay

		GOTO	Again

; This routine is two nested delays

Delay		MOVLW	H'20'
		MOVWF	Loop1
More1		MOVLW	H'FF'
		MOVWF	Loop2		
More2		NOP
		DECFSZ	Loop2,F
		GOTO	More2		
		DECFSZ	Loop1,F
		GOTO	More1
		RETLW	0

		END


Back Download Home Page

Contacts: