; Sigarch.asm ; Simple PIC16F84 Program to flash LEDs ; Include the header file for our target chip #include "p16f84.inc" ; First line, declare that we want a 16F84 PIC ; and that our numbers will be in Hexadecimal ; unless otherwise noted LIST P=16f84, R=HEX ; Tell the programmer what options we want to use ; In this case: ; _WDT_OFF -- Watchdog Timer Off ; _XT_OSC -- Crystal Oscillator ; _CP_OFF -- Code Protect Off __CONFIG _WDT_OFF & _XT_OSC & _CP_OFF ; Variable Declarations ; Here we assign memory locations for our variables ; assign counter1 to register 0x20 counter1 EQU 0x20 ; assign counter2 to register 0x21 counter2 EQU 0x21 ; First column is always for labels. Anything in the first ; column will be interpreted by the assembler as a label Start CLRF PORTB ; Initialize Port B CLRW ; Clear W register BSF STATUS,RP0 ; Select Register Bank 1 MOVWF TRISB ; Set B to all outputs BCF STATUS,RP0 ; select Register Bank 0 CLRF counter1 ; clear counter1 -> register 0x20 CLRF counter2 ; clear counter2 -> register 0x21 Outer_Loop INCF PORTB,F ; increment port B Delay_Loop DECFSZ counter1,f ; DECrement File register and Skip if Zero ; skips next instruction if counter1 is 0 ; after it decrements counter1 GOTO Delay_Loop ; goes back to Delay_Loop DECFSZ counter2,f ; skips next instruction if counter2 is 0 GOTO Delay_Loop ; goes back to Delay Loop ; Net effect of last 4 instructions is to delay ; by about 100ms GOTO Outer_Loop ; Go back to Outer_Loop and repeat indefinitely END ; End of program