All pastes #184909 Raw Edit

Anonymous

public text v1 · immutable
#184909 ·published 2006-09-28 12:36 UTC
rendered paste body
;********************************************************
;*		- Pic Microprojekt -			*
;*							*
;*  PROJEKT ANSVARLIGE:  Henrik Nøhr		*	
;*  NAVN:  Lysdiode opsætning				*
;*  TITEL:   PIC16F84					*
;*  CLOCK: 4 MHz					*
;*  FILE:  diode3.asm					*
;*  WATCHDOGTIMER:  no					*
;*							*
;*  Tænder 8 dioder efter hinanden, afhængig af om en	*
;*  knap er trykket ind. 				*
;*							*
;********************************************************

;******************************************************** 
;*		     CHIP OPTIONS			*
;********************************************************

_CP_OFF		equ	H'3FFF'				;code protect off
_PWRTE_ON	equ	H'3FFF' 			;Power on timer on
_WDT_OFF	equ	H'3FFB'				;watch dog timer off
_XT_OSC		equ	H'3FFD'				;crystal oscillator
__CONFIG       _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC	;configure programmer directive

;******************************************************** 
;*			EQUATES				*
;********************************************************

w       	equ     	0	; register destination numbers.
f	       	equ     	1	

status		equ		03
porta		equ		05		;input
portb		equ		06
trisa		equ		85h		;bank1
trisb		equ		86h		;bank1
cycle		equ		00		;antal gentagelser for delay
temp		equ		20h		;mem register til delay loop
temp1		equ		21h		;loop delay

pa0		equ		05		;page select bit

COUNT1 		equ 14h
COUNT2 		equ 15h
COUNT3 		equ 16h


#define		opsw1		porta,0		;Optical switch 1 (register the tallest packages)
#define		opsw2		porta,1		;Optical switch 2 (register the packages of middle height)
#define		onoff		porta,2		;On/Off button


#define 	push1		portb,0		;Push tall packet off belt
#define 	push2		portb,1		;push medium packat off belt
#define 	belt		portb,2		;start/Stop belt

		list p=16F84

page1		macro	
		bsf		status,pa0	;set up page 1
		endm

page0		macro	
		bcf		status,pa0	;set up page0
		endm
		org		00h		;angiver start adresse

;******************************************************** 
;*		Initialisering				*
;********************************************************

init
		movlw   	1
		tris    	porta		; set porta as inputs

		clrf		portb		;port b (B'00000000')
		page1
		clrf		trisb		;port b output
		page0
	
;******************************************************** 
;*		Selve programmet			*
;********************************************************

turnoff clrf	portb
		goto onoffsw


onoffsw		btfss	onoff
		goto	turnoff
		goto	runloop


runloop		btfss	onoff
		goto	onoffsw
		bsf		belt
		btfss	opsw1
			call pushc1
		btfss opsw2
			call pushc2
		goto runloop

pushc1
		clrf	portb
		bsf		push1
		movlw	0x46
;		call delay		;Cald enough times for the pusher to push the packages off...
		bcf push1 
;		call delay		;Cald enough times for the pusher to get back in position.		
		RETURN


pushc2
		clrf	portb
		bsf		push2
		movlw	0x46
;		call delay		;Cald enough times for the pusher to push the packages off...
		bcf push2
;		call delay		;Cald enough times for the pusher to get back in position.		
		RETURN




;******************************************************** 
;*			  Delay 			*
;********************************************************
 
delay						;delay et sekund
		movwf 15h
		movwf 16h
		movwf 14h
		decfsz COUNT1,1
		goto $-1
		decfsz COUNT2,1
		goto $-4
		movwf 15h
		decfsz COUNT3,1
		goto $-7
		RETURN
END