| This is the Assembler code written in pseudo-English. Note that the compiler ignores anything following a semi-colon. This makes it possible to "comment the code" on a line-by-line basis. You are encouraged to document EVERY step. ;*****Set up the Constants****
CatsEyes suggests the following modifications:
list
p=16F84A ;
list directive to define processor
#include
<p16F84A.inc> ; processor
specific variable definitions
errorlevel -302
; suppress message 302 from list file
__CONFIG
_CP_OFF & _WDT_OFF & _PWRTE_ON & _RC_OSC
The first line specifies the processor you are using, so you
don't have to set it up in MPLAB (or a command line argument if you're using
the command line to assemble your code).
The second line will set up all the processor-specific variable
names for things like Register Files, specific bits within the register files
and configuration bits. In the LED flasher sample code, for example, you can
eliminate the EQUates for the STATUS, TRISA and PORTA registers, as they're
already defined in the include file. In addition, bits within the registers
can be named instead of using the bit number, e.g.
bsf
STATUS, RP0
;Switch to Bank 1
The bank status bit is named "RP0" (which is EQUated
to "5" in the include file). This corresponds more closely to the
code samples given in the processor datasheets.
The third line suppresses the annoying "Register in
operand not in bank 0." warnings. (Of course the bank bits are correct!)
Oddly, this line was omitted from the 16F84A code template.
Finally, the fourth line specifies the configuration word (so
it is saved with the code, rather than you having to remember to specify it in
MPLAB and/or in the programmer software). The configuration word specifies
some fixed operating parameters of the chip such as oscillator modes, code
protection etc. Refer to the section "SPECIAL FEATURES OF THE CPU"
of the datasheet, under "Configuration Bits."
|
Send mail to
ironsidz@hotmail.com with
questions or comments about this web site.
|