Sorry for cluttering your nice forum with such a total noob question, but I'm trying squeeze through the rabbit hole as it were, into the wonderful world (or hellish netherworld?) of PIC programming, but I've hit a snag that is causing me quite a headache.
I am trying to program a PIC16F874A. MPASM is the assembler I'm using.
My goal is to light up an LED on bit 0 of port D. Seems simple eh?
Here is my very simple program:
Code:
#include P16F874A.INC
_CONFIG _FCMEN_OFF&_IESO_OFF&_BOD_OFF&_CPD_OFF&_CP_OFF&_PWRTE_OFF&_WDT_OFF&_INTRC_OSC_NOCLKOUT&_MCLRE_ON
org 0
Start
BSF STATUS,RP0 ;select bank1
BCF TRISD,0 ;set IO pin d0 as output
BCF STATUS,RP0 ;select bank0
BSF PORTD,0 ;TURN ON LED
GOTO $ ;WAIT HERE
END
And here are the extremely annoying contents of the error file:
Error[122] C:\PROGRAMS\HELLOWORLD.TXT 2 : Illegal opcode (_FCMEN_OFF)
Message[302] C:\PROGRAMS\HELLOWORLD.TXT 7 : Register in operand not in bank 0. Ensure that bank bits are correct.
*bangs head against table*
The first error about the opcode confuses me, but it isn't my main gripe, as those config settings (whatever they are) are probably not important to my hello world program.
Indeed, the thing that aggravates me is the second message "register in operand not in bank 0" etc... but the first thing I want my program to do is switch to bank 1, not 0, and for some reason that's not happening.
The first line of my program after START is:
BSF STATUS,RP0
Isn't that supposed to switch me to bank1 (which is where the TRISTD register is)?
Can anybody tell me where I'm going wrong?
Thanks!
Bookmarks