EXPLANATION OF THE PROGRAM

_RC_OSC EQU H’3FFF’

RC is the Resistor and Capacitor for Oscillator, which is the circuit I used in this lesson, sees the Diagram and it is located at the part of memory of H’3FFF’




_WDT_OFF EQU H’3FFB’

The Watchdog Timer is a free running On-Chip RC Oscillator which does not require any external components. This RC oscillator is separate from the RC oscillator of the OSC1/CLKIN pin. That means that the WDT will run even if the clock on the OSC1/CLKIN and OSC2/CLKOUT pins of the device has been stopped, for example, by execution of a SLEEP instruction. During normal operation, a WDT time-out generates a device RESET. If the device is in SLEEP mode, a WDT wake-up causes the device to wake-up and continue with normal operation. The WDT can be permanently disabled by programming configuration bit WDTE as a '0

STATUS EQU 03h
TRISA EQU 85h
PORTA EQU 05h
TRISB EQU 86h
PORTB EQU 06h

This are the register file map see the table 2 at page 7

__CONFIG _WDT_OFF & _RC_OSC

I configure the fuses as the watchdog is off and I used the Resistor /capacitor as the Oscillator. Take note: that there are 2 underscore ( _ ) before CONFIG

Org 00h

PIC starts here on power-up and reset, It means that I started at 00h of memory and stack or it is at the vector see the table 1 at page 6



Bsf STATUS, 5
Movlw 00h
Movwf TRISA
Movlw 00h
Movwf TRISB
Bcf STATUS, 5

BSF means Bit Set F.
The F means that we are going to use a memory location, or register.
STATUS is a register address where it is located at 03h (see the table at 2 at page 7)
And 5 means I use this bit for direct addressing

bit 5 RP0: Register Bank Select bits (used for direct addressing)
01 = Bank 1 (80h - FFh)
00 = Bank 0 (00h - 7Fh)

Movlw b’01010’

Store the 010101 in binary data into W resgister

Movwf PORTA

From W register move the data into PORTA

Movlw b’01010101’

Store the 01010101 in binary data into W register. (Note the first value stored in W register it will be overwrite )

Movwf PORTB

From W register move the data into PORTA

Start
Goto Start

End

No comments: