Searching \ for '[PIC]: Addressing Bank 1 data space' 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/microchip/memory.htm?key=data
Search entire site for: 'Addressing Bank 1 data space'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Addressing Bank 1 data space'
2003\08\19@041700 by Nigel Orr

flavicon
face
I've added some comments to say what I think the code is doing, check if
they are what you expected...

> B1_COUNT     equ     0xA0
> B1_ARRAY    equ     0xA0
> B1_OTHERDATA equ   0xC3
> B1_MOREDATA equ   0xC4
>
> ; A method "foo" is called twice by my main program logic.
> ;
> foo
>     banksel    B1_COUNT ; This is the ONLY reference to B1_COUNT
anywhere:
>     incf    B1_COUNT  ; Increment data stored at 0xA0
>     movlw    B1_ARRAY
>      addwf    B1_COUNT, W     ; Add literal 0xA0 to current value at location
0xA0
>     movwf    FSR      ; Store that as an address
>     incf        INDF  ; Increment the value at register ((contents of
location 0xA0)+0xA0)
>     return

Where is B1_COUNT initialised?

If it starts life as 94 or greater, the value in FSR will overflow

If it starts life as 0xFF, on the first call it will be incremented to
0x00, then it will overwrite itself with 0xA0

There are other options for odd behaviour, I would check very carefully
what the value is set to on entry to 'foo', perhaps transmit it from the
serial port before and after foo is called?  Then come back and tell us
what the results were.

Nigel
--
Nigel Orr, Design Engineer                 spam_OUTnigelTakeThisOuTspamaxoninstruments.co.uk
Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT
              Tel:+44 1467 622332 Fax:+44 1467 625235
                  http://www.axoninstruments.co.uk

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu

2003\08\19@072408 by Bob Ammerman

picon face
What is the state of the IRP bit in STATUS?

Bob Ammerman
RAm Systems

----- Original Message -----
From: "Nigel Orr" <nigelspamKILLspamAXONINSTRUMENTS.CO.UK>
To: <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: Tuesday, August 19, 2003 4:17 AM
Subject: Re: [PIC]: Addressing Bank 1 data space


{Quote hidden}

location
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2003\08\19@121053 by Jim Tellier

picon face
>Bob Ammerman wrote:

> What is the state of the IRP bit in STATUS?

Upon startup, I always do:
   bcf    STATUS, RP0
   bcf    STATUS, RP1
I've not touched the IRP bit directly, but I believe it's supposed to
power-up as '0'.

and
>Nigel Orr wrote

>> ...
> >     incf        INDF  ; Increment the value at register ((contents of
> > location 0xA0)+0xA0)
...
> > Where is B1_COUNT initialised?

prior to this instruction, B1_COUNT was initialized to 0 (long before the
1st call to 'foo').
(sorry, perhaps my code snipped was indeed too brief!)
FSR=0xA0.  Doing 'incf INDF' should increment the contents of 0xA0, and the
result should
be 0xA0 contains 0x01.

and,
> Picdude wrote:
> Just a quick glimpse thru this, I'm wondering whether the destination on
the
> "incf INDF" instruction makes a difference?

That's the gist of what I was thinking, too.   As I pointed out in the
original post, this behavior is *sporadic*... meaning that I see different
results on multiple "power-on, same steps + same data" sequences.  At first
it seemed that it must be a case of FSR getting clobbered during ISR, but
that's not happening.
My understanding is that to access Bank 1 data memory, the upper bit of the
address set in FSR (e.g. 0xA0) being a '1' will effectively do the bank
selection without having to muck with STATUS/RP0.

Thanks to everyone for the ideas... I'm going to try to instrument things a
bit more closely; will let you know what I find!

Jim
> --
> http://www.piclist.com hint: To leave the PICList
> KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu

2003\08\19@153349 by ?q?Debbie=20Hynes?=

flavicon
face
--- Jim Tellier <spamBeGonejimtellierspamBeGonespamCOX.NET> wrote: > >Bob Ammerman wrote:
>
> > What is the state of the IRP bit in STATUS?
>
i tend to include macro files to take care of page/bank selects ... makes it
easier to "see where u are" in the code.
Debbie :)
;**********************************************************************
;MACRO SECTION (I) ... 'bank select' MACROS
;
;STATUS for 'bank select' in STATUS REGISTER
;
;   b6     b5
;   0      0      BANK #0
;   0      1      BANK #1
;   1      0      BANK #2
;   1      1      BANK #3
;**********************************************************************
BANK_0 MACRO
bcf   STATUS,RP0
bcf   STATUS,RP1
ENDM

BANK_1 MACRO
bsf   STATUS,RP0
bcf   STATUS,RP1
ENDM

BANK_2 MACRO
bcf   STATUS,RP0
bsf   STATUS,RP1
ENDM

BANK_3 MACRO
bsf   STATUS,RP0
bsf   STATUS,RP1
ENDM

;******************************************************
;MACRO SECTION (II) ... 'page select' MACROS
;
;STATUS for 'page select' in PCLATH
;
;   b4     b3
;   0      0      page #0
;   0      1      page #1
;   1      0      page #2
;   1      1      page #3
;******************************************************
PAGE_0 MACRO
bcf   PCLATH,4
bcf   PCLATH,3
ENDM

PAGE_1 MACRO
bcf   PCLATH,4
bsf   PCLATH,3
ENDM

PAGE_2 MACRO
bsf   PCLATH,4
bcf   PCLATH,3
ENDM

PAGE_3 MACRO
bsf   PCLATH,4
bsf   PCLATH,3
ENDM


{Quote hidden}

http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu

2003\08\19@222556 by Jim Tellier

picon face
> Debbie Hynes wrote:
> i tend to include macro files to take care of page/bank selects ... makes
it
> easier to "see where u are" in the code.

Thanks for those ideas... I can see the utility in the page select macros,
but why not just use the assembler directive 'banksel' for bank selection?
That way, the assembler "remembers" for you, which bank holds TRISC vs
PORTC, etc.  That's what I generally do throughout my code; (the only reason
I explicitly say "bcf STATUS, RP0", "bcf STATUS, RP1" is to make it more
clearly obvious that I'm killing bank selection upon startup, as opposed to
"clrf STATUS".   So, hey... even assembler can be "self documenting" eh?!
:^)
Jim
> --
> http://www.piclist.com hint: To leave the PICList
> RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu
>

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu

2003\08\20@042228 by Nigel Orr

flavicon
face
pic microcontroller discussion list <> wrote on Tuesday, August 19, 2003
5:10 PM:

> My understanding is that to access Bank 1 data memory, the upper bit
> of the address set in FSR (e.g. 0xA0) being a '1' will effectively do
> the bank selection without having to muck with STATUS/RP0.

That is correct, I often use that, particularly if I need to update a Bank
1 address quickly (in a tight loop which also accesses Bank 0 addresses)

Nigel
--
Nigel Orr, Design Engineer                 EraseMEnigelspamaxoninstruments.co.uk
Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT
              Tel:+44 1467 622332 Fax:+44 1467 625235
                  http://www.axoninstruments.co.uk

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

2003\08\20@135454 by ?q?Debbie=20Hynes?=

flavicon
face
> Thanks for those ideas... I can see the utility in the page select macros,
> but why not just use the assembler directive 'banksel' for bank selection?
> That way, the assembler "remembers" for you, which bank holds TRISC vs
> PORTC, etc.  That's what I generally do throughout my code; (the only reason
> I explicitly say "bcf STATUS, RP0", "bcf STATUS, RP1" is to make it more
> clearly obvious that I'm killing bank selection upon startup, as opposed to
> "clrf STATUS".   So, hey... even assembler can be "self documenting" eh?!
> :^)
> Jim
hmmm ... that's one i hadn't thought of. damn, i've been fiddling with PICs
for over a year now and i'm _still_ a novice. :)
good 1 Jim!
Debbie

http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search

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

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