Professional Documents
Culture Documents
; Filename: F628a_BCD.asm
; Date: OCT. 8, 2016
; Author: Lewis Loflin lewis@bvu.net
; http://www.bristolwatch.com/PIC16F628A/index.htm
; Compiled on MPLAB 8.88
; Demonstrates how to use interrupts with TMR0
;**********************************************************************
__CONFIG _CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON &
_INTOSC_OSC_NOCLKOUT
goto main
main
; count 0-99 in BCD displayed on 8 LEDS PORTB
MOVFW CNT
ANDLW 0x0F ; mask out 4 upper bits
SUBLW 0x0A ; test lower nibble
BTFSS STATUS, Z ; test for dec 10
GOTO LOC1
MOVFW CNT
ADDLW 0x06
MOVWF CNT
; test upper nibble
MOVWF TEMP
SWAPF TEMP ; swap nibbles
MOVFW TEMP
ANDLW 0x0F ; mask off upper 4 bits
SUBLW 0x0A ; test for 0x0A
BTFSS STATUS, Z ; test for dec 10
GOTO LOC1
MOVFW CNT ; upper nibble = 0xA0 add 0x60
ADDLW 0x60
MOVWF CNT
LOC1
MOVFW CNT ; display result
MOVWF PORTB
CALL TMR0_DEL ; any delay routine
INCF CNT ; CNT = CNT + 1
goto main