;************************************************************************* ; Copyright 2004 Hata Akihiro ; ;  第5章 PICアイデア集 ; 5−11 アナログ・コンパレータにヒステリシスを持たせる。 ;------------------------------------------------------------------------- ;プログラムの説明 ;<概要> ; ヒステリシス確認用のテスト・プログラム。 ; ;<動作> ; コンパレータ1入力(RA0)を上昇・下降させLEDの点灯でヒステリシスを確認する。 ;  ; ;------------------------------------------------------------------------- ; ; 2004/08/23 V1.00 初回リリース ; ; ; ; ;------------------------------------------------------------------------- ; CONFIGRATION FUSE ; WDT:Disable OSC:Int RC Code Protect:OFF Power up timer:ON ; OSCILLATOR ; 4MHz ;************************************************************************* ; LIST P=PIC16F628A, R=DEC ;Target Processor INCLUDE P16F628A.INC ; __CONFIG _BODEN_OFF & _WDT_OFF & _INTOSC_OSC_NOCLKOUT & _CP_OFF & _PWRTE_ON & _DATA_CP_OFF & _LVP_OFF & _MCLRE_OFF __idlocs H'0100' ;V1.00 2004/08/23 ; ;------------------------------------------------------------------------- ; DEFINE I/O Port ;------------------------------------------------------------------------- ; PortA ; RA0 input ; RA1 input ; RA2 input ; RA3 C1 OUT output ; RA4 input ; RA5 input ; ; PortB ; RB0 input ; RB1 input ; RB2 input ; RB3 input ; RB4 input ; RB5 input ; RB6 input ; RB7 input ; ;------------------------------------------------------------------------- ; Variables ;------------------------------------------------------------------------- ; ; ; ;------------------------------------------------------------------------- ; Registers ;------------------------------------------------------------------------- ; ;------------------------------------------------------------------------- ; Program code ;------------------------------------------------------------------------- ; ORG H'00' ; Power ON GOTO INITIALIZE ; ; ;------------------------------------------------------------------------- ; Initialize ;------------------------------------------------------------------------- INITIALIZE BSF STATUS,RP0 MOVLW B'11110111' ; Set I/O Port INPUT/OUTPUT MOVWF TRISA MOVLW B'11111111' MOVWF TRISB BCF STATUS,RP0 MOVLW B'00000110' MOVWF CMCON ; Set CMCON ;---------------------- ; OUTPUT Initialize ;---------------------- ;******************************************************* ; MAIN PROGRAM ;******************************************************* MAIN GOTO MAIN ; END