por Bruno Caputo » 26 Nov 2009 21:34
Opa..não havia colocado a parte inicial do código...agora ele vai completo...
;xxxxxxxxxxxxxxxxxxxxx
LIST P=16F628, R=DEC ; Use the PIC16F628 and decimal system
#include "P16F628.INC" ; Include header file
__config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
CBLOCK 0x20 ; Declare variable addresses starting at 0x20
Loop1,Loop2
ENDC
;
; -----------
; INITIALIZE
; -----------
;
ORG 0x000 ; Program starts at 0x000
CLRF PORTA ; Initialize port A
CLRF PORTB ; Initialize port B
BSF STATUS,RP0 ; RAM bank 1
CLRF TRISA ; All pins port A output
CLRF TRISB ; All pins port B output
BCF STATUS,RP0 ; RAM bank 0
;
; ------------------------
; FUNCTION OF PORT A PINS
; ------------------------
;
MOVLW 7
MOVWF CMCON ; Comparators off, all pins digital I/O
;
; ----------
; MAIN LOOP
; ----------
;
Main
;Compara RA0 com RA3. Verifica se RA3 > RA0
MOVLW B'10101100'
MOVWF VRCON
MOVLW B'00000010'
MOVWF CMCON
CALL delay
CALL delay
BTFSC CMCON,6
BSF PORTB,5
GOTO Main
;
; ---------------
; DELAY 250 MSEC
; ---------------
;
delay MOVLW 150
MOVWF Loop1
Outer MOVLW 100
MOVWF Loop2
Inner NOP
NOP
DECFSZ Loop2,F
GOTO Inner ; Inner loop = 5 usec.
DECFSZ Loop1,F
GOTO Outer
RETURN
END