;********************************************************************** ; * ; Filename: ledchaser16F84A.asm * ; Date: 04/09/2008 * ; File Version: 1.00 * ; * ; Author: Pete Griffiths * ; Company: http://picprojects.org.uk * ; * ; * ;********************************************************************** ; * ; Notes: * ; 1. PIC 16F84A datasheet can be downloaded from * ; http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf * ; * ; 2. See also MPASM User Guide(UG) which can be downloaded from: * ; http://ww1.microchip.com/downloads/en/DeviceDoc/33014J.pdf * ; http://picprojects.org.uk/projects/ledchaser/ * ; * ; 3. This code uses Pseudo-instructions listed in the MPASM User * ; guide, Part 4, Appendix A.5 * ; * ; 4. For list of Radix types see MPASM UG Section 3.4, Table 3-3 * ; * ; TO PROGRAM PIC MICROCONTROLLER * ; ------------------------------ * ; Install MPLAB IDE * ; Open this file from the MPLAB IDE application * ; from drop-down menu Configure - Select Device * ; in 'device' box select PIC16F84A, then click Ok * ; from drop-down menu Project - Quickbuild ledchaser16F84A.asm * ; * ; In the same directory as this file you should now find a file * ; named ledchaser16F84A.HEX * ; This file needs to be opened with your programmer application * ; and programmed into the PIC microcontroller * ; * ;********************************************************************** ;********************************************************************** ; If you want to run this code in a simulator environment, uncomment * ; the #define below to remove the real time 300mS delay code * ; ;#define SIMULATOR ;MPASM UG Section 4.18 ;********************************************************************** list p=16F84A ; list directive to define processor ; See MPASM UG Section 4.42 ; #include ; Standard include file ; defines processor specific variable definitions ; See MPASM UG Section 4.41 ;------------------------------------------------------------------------------------ ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The lables following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. ; and also see MPASM UG Section 4.12 __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC ; Code protect off ; Watch Dog timer off ; Power-up timer delay on ; Set oscillator type to HS - High speed crystal/resonator >3.5Mhz ; change to _RC_OSC for resistor/capacitor ; change to _XT_OSC for crystal/resonator <3.5Mhz ;------------------------------------------------------------------------------------ ; Suppress specific warning messages ; see MPASM UG Section 4.29 for errorlevel directive ; see MPASM UG Section 8.4 for assembler message descriptions ; errorlevel -302 ; suppress banksel warning messages during assembly errorlevel -311 ; suppress HIGH operator warning messages during assembly ;------------------------------------------------------------------------------------ ; define variables in General Purpose Register (GPR) memory ; See MPASM UG Section 4.8 ; note: 16F84A GPR start at 0x0C but most other mid-range PICs start at 0x20 ; We use 0x20 here for compatibilty with newer PICs cblock 0x20 copyPORTA ; working variable, holds copy of PORTA copyPORTB ; working variable, holds copy of PORTB ltime ; used by delay function dtime ; used by delay fucnction endc ;------------------------------------------------------------------------------------ ; Define bank select pseudo instructions to make code more readable #define bank0 bcf STATUS,RP0 ; Sel Bank 0 #define bank1 bsf STATUS,RP0 ; Sel Bank 1 ;-------------------------------------------------------------------------------------------------------------------- ; Define constants for left and right bits to end shifts at according to the following: ; PORTA PORTB ; ---x3210 76543210 leftBit equ 3 ;___| | leftBit is always in PORTA rightBit equ 0 ;_______________| rightBit is always in PORTB ; ; note PORTA,4 is open collector so you can't use it ; PORTA,5/6/7 aren't implemented in hardware ; ; See MPASM UG Secdtion 4.27 for definition of equ directive ;-------------------------------------------------------------------------------------------------------------------- ; Program code starts here ; ; See MPASM UG Section 1.7.1, and Example 1-1 ; ; Labels Mnemonics Operands Comments ; Directives ; Macros ; RESET_VECTOR org 0x000 ; see MPASM UG Section 4.50 ; Initialise the I/O ports and variables in this section ; START bank1 ; set to register bank 1 ; this is a pseudo instruction defined on earlier clrf TRISA ; set PORTA as output clrf TRISB ; set PORTB as output bank0 ; set to register bank 0 ; this is a pseudo instruction defined on earlier clrf copyPORTA ; initialise variable movlw 1<