(noob)hello world?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2007
    Posts
    2

    Default (noob)hello world?

    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!
    Last edited by m4gill4; - 30th November 2007 at 00:50.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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.
    Code:
        errorlevel  -302
    Of course, that's automatic in PicBasic, which is the language we talk about on this forum.
    <br>
    DT

  3. #3
    Join Date
    Nov 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    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!

Similar Threads

  1. Welcome into PIC world
    By shafi008 in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 29th April 2009, 07:51
  2. Remote Control World !
    By iugmoh in forum General
    Replies: 4
    Last Post: - 23rd April 2008, 00:03
  3. wired world
    By jcleaver in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th February 2007, 17:23
  4. Is the world ready for TTL RS-232 serial?
    By hansknec in forum Serial
    Replies: 7
    Last Post: - 26th July 2005, 15:56
  5. pulsin fails in real world
    By peu in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th March 2005, 11:32

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts