;********************************************************* ;PROGRAM TO COUNT FROM 0 TO 9 ON FOUR PORTB PINS OF A ; PIC16C71 Microcontroller. ; ; This program may be assembled using MAPSM ; ;AUTH: Peter Gray, modified Gorry Fairhurst ;VERS: 1.0 = 23/10/97 1.1 16/11/99 ; ;*************************************************************** ;*** The first sections are cmmands to the assembler to tell ;*** it what type of microcontroller (list) is being programmed ;*** and to define various registers and values relating to ;*** this type of controller list p=16C71 ; *** Make PC point to MAIN on reset *** ORG 0 ;Reset vector for 16C71 PIC GOTO MAIN ;***** GENERAL EQUATES ***** ;These are definitions that make the code easier to follow W equ 0 F equ 1 STATUS equ 3 RP0 equ 5 PORTB equ 6 LS4 equ H'F0' COUNT1 equ H'0c' COUNT2 equ H'0d' COUNT3 equ H'0e' ;MACROS (in-line procedure definitions) PORT_INIT macro bsf STATUS,RP0 ;select bank 1 movlw LS4 ;select pins 0 - 3 movwf PORTB ;as O/Ps bcf STATUS,RP0 ;select bank 0 endm CLEAR_PORT macro clrf PORTB movlw .10 movwf COUNT3 endm ; *** Start of main program *** org 5 MAIN PORT_INIT CLEAR call DELAY CLEAR_PORT LOOP call DELAY incf PORTB decfsz COUNT3 goto LOOP goto CLEAR ;delay subroutine (does nothing for several instructions) DELAY NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP incfsz COUNT1 ;wait 255 goto DELAY incfsz COUNT2 ;wait 255 goto DELAY return END