| ;************************************************************************************************************* |
| ; |
|
TITLE:
New 16F84
|
|
|
| ; |
AUTHOR:
|
|
DATE:
|
|
| ;************************************************************************************************************* |
| ;State
here what the program does |
| ;************************************************************************************************************* |
| ; |
DEFINITIONS |
| ;************************************************************************************************************* |
| list
P=PIC16C84, R=D |
;Define
PIC type and radix (H=Hex, D=Decimal). |
| include "P16C84.INC" |
;P16C84.INC
is a file containing definitions of PIC ;registers |
| ;******
REGISTER USAGE ****** |
|
| |
;For
PIC16C84, user RAM starts at 0Ch. |
temp1
|
equ |
0Ch |
;Temporary
register 1 |
| temp2 |
equ |
0Dh |
;Temporary
register 2 |
| count |
equ |
0Eh |
;Counter
register |
| ;************************************************************************************************************* |
;
|
VECTORS |
| ;************************************************************************************************************* |
| |
;The
PIC16C84 vectors live at the bottom of memory (0000h-0007h) |
| org |
0000h |
|
;Reset
vector for PIC16C84 is at 0000h |
| |
goto |
start |
;Go
to main program start |
| org |
0004h |
|
;Interrupt
vector for PIC16C84 is at 0004h |
| |
goto |
inter |
;Go
to start of interrupt service routine |
| org |
0008h |
|
;First
location available to programs |
| ;************************************************************************************************************* |
| ; |
SUBROUTINES |
| ;************************************************************************************************************* |
;
Subroutines are placed after the vectors at the bottom
of memory so that small programs run faster.
;Code for subroutines goes here |
| ;************************************************************************************************************* |
| ; |
MAIN
PROGRAM |
| ;************************************************************************************************************* |
| ;******INITIALISATION
****** |
|
;Before
using the I/O ports, data direction registers must be
set up. A '1' in these registers sets the ;corresponding
port
;line to an input, and a '0' makes the corresponding line an output. |
| |
| start |
bsf |
STATUS,RP0 |
;Select
special register set |
| |
movlw |
b'11111' |
;Set
port A data direction to 'all I/P' |
| |
movwf |
TRISA |
|
| |
movlw |
b'00000000' |
;Set
port B data direction to 'all O/P' |
| |
movwf |
TRISB |
|
| |
bcf |
STATUS,RP0 |
;Select
normal register set |
| |
| ;******
MAIN PROGRAM ****** |
|
| ;The
code for the main program goes here |
| ;************************************************************************************************************* |
| ; |
INTERRUPT
SERVICE ROUTINE |
|
| ;************************************************************************************************************* |
| |
;The
interrupt service routine (if required) goes here |
| inter |
|
| |
END |
|
;All
programs must end with this |