tuta4 microcontrollers and electronics,

2
; TUTA4.ASM 11MAR02 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; 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 ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; using aliases, bit names and conditional loops #DEFINE PAGE0 BCF STATUS,5 #DEFINE PAGE1 BSF STATUS,5 STATUS EQU H'03' ; STATUS register TRISB EQU H'86' ; Port B direction register PORTB EQU H'06' ; Port B data register W EQU 0 ; Working register flag F EQU 1 ; File register flag C EQU 0 ; Carry flag 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 ; clear Port B data register PAGE1 ; PAGE1 CLRF TRISB ; Port B direction register for output PAGE0 ; PAGE0 LOOP1 MOVLW 1 ; load value of 1 into Working register MOVWF PORTB ; load this value as data into Port B BCF STATUS,C ; clear Carry flag LOOP2 RLF PORTB,F ; rotate value of PORTB left by 1 logical place

Upload: traian-vladu

Post on 06-Dec-2015

4 views

Category:

Documents


2 download

DESCRIPTION

microcontrollers and electronics,MCU Unit,beginners course,

TRANSCRIPT

Page 1: TUTA4 microcontrollers and electronics,

; TUTA4.ASM 11MAR02

;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ; 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;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

; using aliases, bit names and conditional loops

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

STATUS EQU H'03' ; STATUS registerTRISB EQU H'86' ; Port B direction registerPORTB EQU H'06' ; Port B data registerW EQU 0 ; Working register flagF EQU 1 ; File register flagC EQU 0 ; Carry flag

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

CLRF PORTB ; clear Port B data registerPAGE1 ; PAGE1CLRF TRISB ; Port B direction register for

outputPAGE0 ; PAGE0

LOOP1 MOVLW 1 ; load value of 1 into Working register

MOVWF PORTB ; load this value as data into Port B

BCF STATUS,C ; clear Carry flag

LOOP2 RLF PORTB,F ; rotate value of PORTB left by 1 logical place

BTFSS STATUS,C ; check Carry flag is setGOTO LOOP2 ; this command is actioned only

if PORTB is not yet 0; the program jumping back to

address LOOP2GOTO LOOP1 ; this command is only actioned

when PORTB now = 0

END ; final statement