User`s guide

MPLAB
®
IDE User’s Guide
DS51519B-page 36 © 2006 Microchip Technology Inc.
FIGURE 2-13: TEMPLATE FILE – MAIN
When any source file is opened, you are automatically in the editor. Type in this code
beneath Main:
clrf WREG
movwf PORTC ; clear PORTC
movwf TRISC ; configure PORTC as all outputs
Init
clrf COUNT,A ; initialize counter
IncCount
incf COUNT,F,A
movf COUNT,W,A ; increase count and
movwf PORTC ; display on PORTC
call Delay ; go to Delay subroutine
goto IncCount ; infinite loop
Delay
movlw 0x40
movwf DVAR2,A ; set outer delay loop
DelayOuter
movlw 0xFF
movwf DVAR,A ; set inner delay loop
DelayInner
decfsz DVAR,F,A
goto DelayInner
decfsz DVAR2,F,A
goto DelayOuter
return