school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

timer.asm (746B)


      1 start: 
      2 init: 
      3 	clrf    PORTA          	; make sure port A output latches are low 
      4 	clrf    PORTB          	; make sure port B output latches are low 
      5 	bsf     STATUS,RP0     	; select memory bank 1 
      6 	movlw 	b'11111111'    	; set port A data direction to inputs 
      7 	movwf   TRISA         
      8 	movlw   b'00000000'    	; set port B data direction to outputs 
      9 	movwf   TRISB          
     10 	bcf     STATUS,RP0     	; select memory bank 0 
     11 
     12 	bsf	INTCON, INT0IE
     13 	bsf	INTCON, GIE
     14 
     15 	counter1 EQU B8
     16 
     17 	goto    main 
     18 
     19 interrupt:
     20 	movf B0, W
     21 	movwf counter1
     22 	goto countdown
     23 
     24 countdown:
     25 	call wait1000ms
     26 	decfsz counter1, F
     27 	goto countdown
     28 
     29 	bcf INTCON, INT0IF
     30 	
     31 	retfie
     32 
     33 main: 
     34 	call 	readadc0
     35 	movf	B0, W
     36 	movwf	PORTB
     37 
     38 	goto 	main
     39 
     40 	END		       	; ends the program