This application demonstrates how the Bank 1 bits are accessed by first setting the "RP0" bit of the the "STATUS" register. This application was presented in the first edition of the book as the first hardware application. This code will make RB0 an output and drive it low before going into an endless loop. The original purpose of this code was to demonstrate how to create a working PICmicro MCU application that turned on an LED.
When simulating this application, make sure that you observe the change in RP0 (bit 5) of STATUS at the "bsf STATUS, RP0" and "bcf STATUS, RP0" instructions.
The source code is listed below, or it can be accessed from the CD-ROM by clicking Here.
title "RegAddr - Turn on a LED" ; ; This was the First Program to be Burned in and Run in a PICmicro ; MCU in the first edition of "Programming and Customizing the PIC ; Microcontroller" ; ; The Program simply sets up Bit 0 of Port "A" to Output and then ; Sets it Low. ; ; Hardware Notes: ; Reset is tied through a 4.7K Resistor to Vcc and PWRT is Enabled ; A 220 Ohm Resistor and LED is attached to PORTB.0 and Vcc ; ; Myke Predko ; ; 99.11.13 - Updated for MPLAB Operation ; ; 96.05.17 - Created ; LIST P=16F84, R=DEC INCLUDE "p16f84.inc" ; Registers __CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON PAGE ; Mainline of RegAddr org 0 clrf PORTB ; Clear all the Bits in Port "B" bsf STATUS, RP0 ; Have to go to Page 0 to set Port Direction bcf TRISB ^ 0x080, 0 ; Set RB0 to Output bcf STATUS, RP0 ; Go back to Page 0 Finished goto $ end
No comments:
Post a Comment