This application demonstrates the basic operation of the PICmicro by looping five times and in each loop, adds "i" to "j". Once this has been done five times, execution goes into a "hardloop".
As the first application you will be working with, it is designed to just execute under the MPLAB IDE simulator. The application is not designed to be loaded into an actual PICmicro microcontroller.
The source code is listed below, or it can be accessed from the CD-ROM by clicking Here.
title "FirstAp - First PICMicro Application" ; ; This Application is a First PICMicro Application to demonstrate how ; MPLAB works. The Application code itself simply Adds two Variables ; together inside a loop. ; ; ; Hardware Notes: ; Simulated PIC16F84 Running at 4 MHz ; ; Myke Predko ; 99.12.23 ; LIST P=16F84, R=DEC INCLUDE "p16f84.inc" ; Register Usage CBLOCK 0x020 ; Start Registers at End of the Values i, j, k ENDC PAGE __CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF ; Mainline of FirstAp org 0 movlw 1 ; Initialize the Variables movwf i movlw 2 movwf j movlw 3 movwf k ; For k = 0 to 5 // Loop 5x movlw 5 movwf k Loop movf i, w ; Add "i" and "j" and Put the Result in "j" addwf j, f decfsz k, f ; Decrement "k" until it's equal to Zero goto Loop goto $ ; Loop Forever when Done end
No comments:
Post a Comment