PDA

View Full Version : (noob)hello world?



m4gill4
- 30th November 2007, 00:24
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:



#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!

Darrel Taylor
- 30th November 2007, 00:52
Message 302 is just annoying, and of not much use.
It's like "Hey buddy, did you set the bank bits?" after every statement. :(

Here's one way to turn if off.
errorlevel -302
Of course, that's automatic in PicBasic, which is the language we talk about on this forum.
<br>

m4gill4
- 30th November 2007, 01:23
ahh, apologies. I'm so new at this that I didn't realize this forum is for a different language than I'm using *laugh*. I'll try and find a forum that is more specific to assembly and mpasm.

Thanks for the help!