tuta9 microcontrollers and electronics,

2
; TUTA9.ASM 11MAR02 ; using single switch on Port A to increment Port B LED count ; showing how bit testing can be used to test switch status ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; Configuration data ; PICmicro MCU type: 16F84 ; Oscillator: RC mode, slow, VR1 fully clockwise (max.rate) ; LCD display: off ; 7-segment display:off ; Version 2 board settings: J14 links: Digital ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; ; The following line embeds configuration data into the PICmicro __CONFIG H'3FFB' ; RC mode ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #DEFINE PAGE0 BCF STATUS,5 #DEFINE PAGE1 BSF STATUS,5 STATUS EQU H'03' ; TRISA EQU H'85' ; PORTA EQU H'05' ; TRISB EQU H'86' ; PORTB EQU H'06' ; W EQU 0 ; F EQU 1 ; COUNT EQU H'20' ; ORG 0 ; Reset vector GOTO 5 ; Goto start of program ORG 4 ; Interrupt vector GOTO 5 ; Goto start of program ORG 5 ; Start of program memory CLRF PORTB ; CLRF COUNT ; PAGE1 ; MOVLW B'00000001' ; RA0 as input MOVWF TRISA ; CLRF TRISB ; PAGE0 ; LOOP BTFSS PORTA,0 ; test bit 0 of Port A, is it set (= 1)?

Upload: traian-vladu

Post on 06-Dec-2015

217 views

Category:

Documents


5 download

DESCRIPTION

microcontrollers and electronics,MCU Unit,beginners course,

TRANSCRIPT

Page 1: TUTA9 microcontrollers and electronics,

; TUTA9.ASM 11MAR02; using single switch on Port A to increment Port B LED count; showing how bit testing can be used to test switch status

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; Configuration data ; PICmicro MCU type: 16F84 ; Oscillator: RC mode, slow, VR1 fully clockwise (max.rate) ; LCD display: off ; 7-segment display:off ; Version 2 board settings: J14 links: Digital ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;; The following line embeds configuration data into the PICmicro

__CONFIG H'3FFB' ; RC mode;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#DEFINE PAGE0 BCF STATUS,5#DEFINE PAGE1 BSF STATUS,5

STATUS EQU H'03' ;TRISA EQU H'85' ;PORTA EQU H'05' ;TRISB EQU H'86' ;PORTB EQU H'06' ;W EQU 0 ;F EQU 1 ;

COUNT EQU H'20' ;

ORG 0 ; Reset vectorGOTO 5 ; Goto start of programORG 4 ; Interrupt vectorGOTO 5 ; Goto start of programORG 5 ; Start of program memory

CLRF PORTB ;CLRF COUNT ;PAGE1 ;MOVLW B'00000001' ; RA0 as inputMOVWF TRISA ;CLRF TRISB ;PAGE0 ;

LOOP BTFSS PORTA,0 ; test bit 0 of Port A, is it set (= 1)?

GOTO LOOP ; no, it's = 0, so got back to LOOP

INCF COUNT,F ; yes, it's = 1 so increment count

MOVF COUNT,W ; get COUNT valueMOVWF PORTB ; output it to PORTBGOTO LOOP ; repeat

END ; final statement