Searching \ for 'What is MPASM error code 302' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/language/index.htm?key=asm
Search entire site for: 'What is MPASM error code 302'.

Truncated match.
PICList Thread
'What is MPASM error code 302'
1996\04\09@202628 by Wilf Melling

flavicon
picon face
I have made a start on my very first PIC project, it is to be a home
alarm system (hopefully). So here my very first plea for help, I keep
getting the following message. I have read the manuals but the answer
does not jump out at me.

Message[302] C:\MPASM\HALARM.ASM 40 : Argument out of range.  Least
significant bits used.

Code sample with line numbers:-
39        Movlw   PORT_B_OUT      ;Define PORTB
40        Movwf   TRISB           ;as output

PORT_B_OUT   EQUates to b11111111

If anyone as any tips or know of any similar projects that have code
available to look at I would be VERY grateful.

TIA


--
Wilf Melling
Tel. +44 802 633888

1996\04\09@205810 by Dave Ritchie

flavicon
face
> Message[302] C:\MPASM\HALARM.ASM 40 : Argument out of range.  Least
> significant bits used.
>
> Code sample with line numbers:-
> 39        Movlw   PORT_B_OUT      ;Define PORTB
> 40        Movwf   TRISB           ;as output
>
> PORT_B_OUT   EQUates to b11111111
>
> If anyone as any tips or know of any similar projects that have code
> available to look at I would be VERY grateful.
>
> TIA
>
>
> --
> Wilf Melling
> Tel. +44 802 633888
>

I would start by changing this constant to decimal and retrying the
assembly - the EQU function of the assembler may be getting confused
here.....

-- Dave Ritchie
former assember maintainer for HP....
spam_OUTderTakeThisOuTspamatl.hp.com

1996\04\09@210020 by Andrew Warren

face
flavicon
face
Wilf Melling <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I have made a start on my very first PIC project, it is to be a home
> alarm system (hopefully). So here my very first plea for help, I
> keep getting the following message. I have read the manuals but the
> answer does not jump out at me.
>
> Message[302] C:\MPASM\HALARM.ASM 40 : Argument out of range.  Least
> significant bits used.
>
> Code sample with line numbers:-
> 39        Movlw   PORT_B_OUT      ;Define PORTB
> 40        Movwf   TRISB           ;as output
>
> PORT_B_OUT   EQUates to b11111111

Wilf:

This has nothing to do with your problem, but if you want all the
PORTB pins to be outputs, PORT_B_OUT must equate to 00000000.

Ok...

The MPASM message refers not to PORT_B_OUT but to TRISB.

If you look at the instruction set for your PIC, you'll see that
register-oriented instructions only have room for 7-bit register
addresses, so they can only address 128 registers.  To accomodate
more than 128 registers, PICs employ a banking scheme that uses a few
bits of the STATUS register to select from multiple 128-register
banks.

If you try to directly access a register in any bank other than Bank
0, MPASM won't be able to fit the register's 8-bit address into the
instruction.  Instead, it'll just use the low 7 bits of the
register's address and generate the message you're seeing.

TRISB is located at address 086H, which puts it in Bank 1.  To access
it, you need to select bank 1 (by setting the RP0 bit in the STATUS
register), then write to register 006H.  Before accessing registers on
Bank 0, you'll need to switch back to that page by clearing the
RP0 bit.  Your code should look like this:

   BSF     STATUS,RP0

       MOVLW   PORT_B_OUT
   MOVWF   080H ^ TRISB

   BCF     STATUS,RP0

The "080H ^ TRISB" exclusive-ORs the TRISB address with 080H, thereby
clearing the high bit of the address... It's equivalent to "07FH &
TRISB", "TRISB - 128", and "006H".

-Andy

Andrew Warren - fastfwdspamKILLspamix.netcom.com
Fast Forward Engineering, Vista, California
http://www.geocities.com/SiliconValley/2499

1996\04\09@234212 by Byron A Jeff

face picon face
{Quote hidden}

That's a great explaination Andy. Now can I ask a dumb question?
The 16C84 Datasheet (and I assume the others too) state that the FSR
will utilize all 8 bits of the file address on indirection. So would
the following work?

  movlw     TRISB
  movwf     FSR
  movlw     .0     ; Note that 0 bits are required for output
  movwf     INDF

It's the same number of instructions but I find it slightly more straight-
forward personally.

BTW I just re-read the databook and in fact the IRP bit in the status
register is prepended to the FSR giving a nine bit address. So in fact
4 128 register pages are accessible using indirection. Cool.

BAJ

1996\04\10@001802 by Andrew Warren

face
flavicon
face
Byron A Jeff <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU> wrote:

> That's a great explaination Andy. Now can I ask a dumb question? The
> 16C84 Datasheet (and I assume the others too) state that the FSR
> will utilize all 8 bits of the file address on indirection. So would
> the following work?
>
>    movlw     TRISB
>    movwf     FSR
>    movlw     .0     ; Note that 0 bits are required for output
>    movwf     INDF
>
> It's the same number of instructions but I find it slightly more
> straight- forward personally.

   Byron:

   Yes, that will work perfectly.  Keep in mind that, although it's
   no longer than the bank-switching code FOR ACCESSING ONE
   REGISTER, it's much less efficient for cases that require
   multiple register accesses.

> BTW I just re-read the databook and in fact the IRP bit in the
> status register is prepended to the FSR giving a nine bit address.
> So in fact 4 128 register pages are accessible using indirection.

   Well, yeah... If any of the 16C6x, 7x, or 8x parts had more than
   2 pages, it'd be pretty useful.

   -Andy

Andrew Warren - fastfwdspamspam_OUTix.netcom.com
Fast Forward Engineering, Vista, California
http://www.geocities.com/SiliconValley/2499

1996\04\10@132120 by John Payson

flavicon
face
> >    movlw     TRISB
> >    movwf     FSR
> >    movlw     .0     ; Note that 0 bits are required for output
> >    movwf     INDF
> >
> > It's the same number of instructions but I find it slightly more
> > straight- forward personally.
>
>     Byron:
>
>     Yes, that will work perfectly.  Keep in mind that, although it's
>     no longer than the bank-switching code FOR ACCESSING ONE
>     REGISTER, it's much less efficient for cases that require
>     multiple register accesses.

While in most cases it makes more sense to use direct addressing with RP0
set/unset as appropriate, indirect addressing can be useful when rapidly
accessing registers in both banks.  For example, if you need rapidly and
repeatedly set TRISB and PORTB, it may make sense to point FSR to TRISB, so
that it may be accessed without any intermediate accesses to RP0.  This
technique can pay off especially well when trying to rapidly read the EEPROM
on a 16C84 [point FSR to EECTRL1].

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...