Searching \ for '[PIC]: Addresses for 18f452 - 20 bits???' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=18F
Search entire site for: 'Addresses for 18f452 - 20 bits???'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Addresses for 18f452 - 20 bits???'
2003\03\08@205449 by John Nall

flavicon
face
Could someone explain to me why the following code produces a warning,
and the address in the goto at address 0 is 1FF rather than 3FE??  I
feel like it has to do with banks, but don't understand what I have to
do to make it work.  (Disclaimer:  I'm new at this, but I'm working hard
and reading the FM into the wee hours of  the morning.  And I know about
the interrupt address and all that -- this only purpose of the code is
to test the 20-bit address for the goto).

LOC  OBJECT CODE     LINE SOURCE TEXT
 VALUE

              00001         LIST P=18F452, F=INHX32
              00002         #include <p18f452.inc>

0000           00004         org 0x00
Warning [202] : Argument out of range. Least significant bits used.
0000 EFFF F001 00005                 goto    MyStart
03FE           00006                 org     0x3fe
03FE           00007 MyStart:
03FE 6AE8      00008                 clrf    WREG
0400 6E82      00009                 movwf   PORTC
0402 6E94      00010                 movwf   TRISC

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\08@222344 by Daniel Imfeld

picon face
I think it is working correctly.  I can't comment on the warning that
the assembler is generating since I can't reproduce it in MPLAB 6.1.

I looked at the opcode generation in a few test cases and it appears
that the address in the opcode is the address in 16-bit words, not in
bytes.  Note that 0x1FF * 2 = 0x3FE.  For example, if you write GOTO
0x004, MPASM generates EF02 F000, which goes to address 2.  The data
sheet doesn't seem to mention this, but it can be deduced from the fact
that the PIC18 series has a 2 MB address space for program memory, but
the goto instruction only uses 20 bits, enough for 1 MB.  The program
memory is still normally addressed in bytes so that the TBLRD and TBLWT
instructions can read and write individual bytes of program memory,
instead of being limited to word boundary operations.  Anyway,
everything is working as you want it to.

Daniel Imfeld


On Saturday, March 08, 2003 5:50 PM, John Nall <spam_OUTjnall01TakeThisOuTspamALLTEL.NET>
wrote:

{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\03\09@084215 by John Nall

flavicon
face
At 07:22 PM 3/8/2003 -0800, Daniel Imfeld wrote:

> >I think it is working correctly.  I can't comment on the warning that
>the assembler is generating since I can't reproduce it in MPLAB 6.1.


The warning is generated by gpasm.  When I run the same program with mpasm
(the MPLAB 6.1 version) I did not get  the warning there.  But since I did
get the same 1FF address I assumed  that perhaps the two assemblers had
different default list options set.

So far as your explanation, I am going to spend some time studying it this
morning.  At a cursory glance it looked reasonable, but I want to
understand exactly what you are telling me.  Guess I will then run it
through the simulator and see how it does.  The proof of the pudding..... :-)

Thanks much, John

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\09@085912 by Olin Lathrop

face picon face
> Could someone explain to me why the following code produces a warning,
> and the address in the goto at address 0 is 1FF rather than 3FE??

Remember that instructions on the 18 family always start at an even address.
The low bit of the target address therefore isn't stored in the GOTO
instruction.  As for the assembler warning, I don't understand it.  It makes
no sense.  It appears to me you are doing everything right (other than using
absolute mode of course).  It is not possible for a GOTO to be out of range
on the 18 family, and I've never gotten this message.  Perhaps some obscure
warning bug in absolute mode?

> I
> feel like it has to do with banks, but don't understand what I have to
> do to make it work.

Banks refers to the segmentation of the data memory space, not the program
memory space.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\09@090322 by Olin Lathrop

face picon face
> The warning is generated by gpasm.

Arrgh!

You might have mentioned you were using non-standard tools.  I wasted a bit
of time trying to figure out where that warning came from because it didn't
look to me like there should be a warning at all.  Use the MPLAB tools, or
at least point out that you're not so most of us can just hit DELETE.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\09@092155 by John Nall

flavicon
face
At 09:01 AM 3/9/2003 -0500, Olin wrote:

> > The warning is generated by gpasm.
>
>Arrgh!
>
>You might have mentioned you were using non-standard tools.  I wasted a bit
>of time trying to figure out where that warning came from because it didn't
>look to me like there should be a warning at all.  Use the MPLAB tools, or
>at least point out that you're not so most of us can just hit DELETE.

Good point, and I will do that next time.  However, my question (which is
why the address was 1FF rather than 3FE) would still have been there with
the MPLAB tools.   Your explanation (in the earlier reply) was exactly what
I needed, and I do apologise for spoiling your Sunday morning with
gpasm.  :-)  I kind of feel duty bound to experiment with the Gnu tools
even though it is clear that right now the MPLAB platform is the best way
to go.  One of these days they may start charging for it....

Thanks again, Olin.  You've helped me several times and I appreciate it a
lot.  Underneath that rough exterior beats a heart of pure gold! :-)

John

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\09@120824 by John Nall

flavicon
face
At 07:22 PM 3/8/2003 -0800, Daniel Imfeld  wrote:

> >The data
>sheet doesn't seem to mention this, but it can be deduced from the fact
>that the PIC18 series has a 2 MB address space for program memory, but
>the goto instruction only uses 20 bits, enough for 1 MB.

Yeah, that is one of those things that after I understand it, it then is so
obvious that I wonder why in the world I didn't see it to begin with?   Oh
well.   Back to the struggle with the data sheet.  My hat is REALLY off to
the people who worked with PIC's back when there was no expertise around to
answer such questions. :-)

John

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\03\09@213338 by Scott Dattalo

face
flavicon
face
On Sun, 9 Mar 2003, John Nall wrote:

> At 07:22 PM 3/8/2003 -0800, Daniel Imfeld wrote:
>
> > >I think it is working correctly.  I can't comment on the warning that
> >the assembler is generating since I can't reproduce it in MPLAB 6.1.
>
>
> The warning is generated by gpasm.  When I run the same program with mpasm
> (the MPLAB 6.1 version) I did not get  the warning there.  But since I did
> get the same 1FF address I assumed  that perhaps the two assemblers had
> different default list options set.

John

Don't be afraid of Olin's bitching about gpasm. I use it nearly every day
for the 18f452 without any problems. If there are any spurious warnings
then those warnings are in MPASM versions less than 6.0 too. If you find a
bug, then either send it to me, Craig Franklin, the GNUPIC mailing list,
or even this list.

Scott

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

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