Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
list p=16F88
#include <p16f88.inc>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
ERRORLEVEL -302
;***************************************************************
;***************************************************************
org 0x0000
goto INIT
NOP
NOP
NOP
NOP
org 0x0005
;
INIT BSF STATUS,RP0 ;Bank1
BSF OSCCON,IRCF1 ;set oscilator
BSF OSCCON,IRCF2 ; to 4Mhz
BSF TRISA,0 ;RA0 input
BCF TRISA,3 ;RA3 output (C1OUT)
CLRF TRISB ;All PortB output
MOVLW b'11100010'
MOVWF CVRCON ;Configure internal Vref
MOVLW b'00000010'
MOVWF CMCON ;set internally ref'ed comparators
BSF PIE2,CMIE ;interupt enable
BCF STATUS,RP0 ;Bank0
BSF INTCON,PEIE ;interupt enable
BSF INTCON,GIE ;interupt enable
LOOP2 NOP
LOOP1 BTFSS PIR2,CMIF ;Wait until compare interupt
GOTO LOOP1
MOVLW b'01000000'
BSF STATUS,RP0 ;Bank1
ANDWF CMCON,0
BCF STATUS,RP0 ;Bank0
MOVWF PORTB
BCF PIR2,CMIF ;reset comparator interupt
GOTO LOOP2
;***************************************************************
list p=16F88
#include <p16f88.inc>
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
ERRORLEVEL -302
;***************************************************************
ORG 0x0000
GOTO INIT
ORG 0x0004
GOTO INTERUPT
;
INIT BSF STATUS,RP0 ;Bank1
BSF OSCCON,IRCF1 ;set oscilator
BSF OSCCON,IRCF2 ; to 4Mhz
BSF TRISA,0 ;RA0 input
BCF TRISA,3 ;RA3 output (C1OUT)
CLRF TRISB ;All PortB output
MOVLW b'11100010'
MOVWF CVRCON ;Configure internal Vref
MOVLW b'00000010'
MOVWF CMCON ;Internally ref'ed comparators
BSF PIE2,CMIE ;interupt enable
BCF STATUS,RP0 ;Bank0
BSF INTCON,PEIE ;interupt enable
BSF INTCON,GIE ;interupt enable
LOOP NOP
GOTO LOOP
INTERUPT MOVLW b'01000000'
BSF STATUS,RP0 ;Bank1
ANDWF CMCON,0
BCF STATUS,RP0 ;Bank0
MOVWF PORTB
BCF PIR2,CMIF ;reset comparator interupt
RETFIE
END
gramo said:just on the f88 comparators and the A/D converters, are they the same as the 16f877, ie, could i run a 877 program on a f88 (using a/d and comparitor settings) with the only loss of the additional ports?