Searching \ for 'Quick question...' 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/index.htm?key=quick+question
Search entire site for: 'Quick question...'.

Truncated match.
PICList Thread
'Quick question...'
1998\03\10@183446 by Calvin

flavicon
face
How can I define a register (i.e. W_Temp) in several banks at the same time?

Calvin

1998\03\10@191630 by Andrew Warren

face
flavicon
face
Calvin <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> How can I define a register (i.e. W_Temp) in several banks at the
> same time?

Calvin:

   W_Temp  EQU     [any register on page 0]
   W_Temp1 EQU     W_Temp + 0x80

In your interrupt service routine -- that IS what you're using this
for, right? -- just refer to W_Temp.

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\03\10@193612 by Calvin

flavicon
face
> How can I define a register (i.e. W_Temp) in several banks at the
> same time?

   Calvin:

       W_Temp  EQU     [any register on page 0]
       W_Temp1 EQU     W_Temp + 0x80

       In your interrupt service routine -- that IS what you're
       using this for, right? -- just refer to W_Temp.

         -Andy


Andy,

maybe I am missing something, could you explain me how this works?

Calvin

1998\03\10@194830 by TONY NIXON 54964

flavicon
picon face
> How can I define a register (i.e. W_Temp) in several banks at the same time?
>
> Calvin
>

I am assuming this question is about context saving when servicing an
interrupt with unknown RAM page settings.

There was some discussion about this a while ago and, from memory I
think it was Andy?? who came up with code similar to the following.

The W_Hold registers are in RAM page 0 and 1
W_Hold (b) = W_Hold (a) + 128

irqvec
movwf W_Hold        ; store w reg - ram page 0 or 1
swapf status,w
bcf status,rp0      ; ram page 0
movwf S_Hold        ; store status in RP 0
movf pclath,w       ; save rom page info
movwf pclsave
movf fsr,w
movwf F_Hold
; assuming IRQ code is in ROM page 0
; for GOTO's etc
clrf pclath

Regards

Tony

PicNPoke Multimedia 16F84 Beginners PIC Tools.

PicNPoke - PicNPlay - PicNPlan - PicNPrep - PicNPost
Plus DT type saver.
New addition - PicNPort I/O Tutor.

http://www.dontronics.com/picnpoke.html

1998\03\11@021604 by Andrew Warren

face
flavicon
face
Calvin <PICLISTspamKILLspamMITVMA.MIT.EDU> wrote:

> > > How can I define a register (i.e. W_Temp) in several banks at
> > > the same time?
> >
> > W_Temp  EQU     [any register on page 0]
> > W_Temp1 EQU     W_Temp + 0x80
> >
> > In your interrupt service routine -- that IS what you're
> > using this for, right? -- just refer to W_Temp.
>
> maybe I am missing something, could you explain me how this works?

Calvin:

I'd really like to, but I just don't have time right now.

Tell you what... If no one else jumps in and explains the whole thing
in the next day or so, I'll find time to explain it.

-Andy

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

1998\03\11@034118 by Rick Dickinson

flavicon
face
At 11:10 PM 3/10/98 -0800, Andrew Warren wrote:
{Quote hidden}

Consider this a jump-in....

Since the addresses of registers at the same place in both banks are 0x80
locations apart, we simply declare W_Temp to be a register somewhere on
page 0, and W_Temp1 to be a register 0x80 locations higher in memory.
W_Temp1 is thus in the same place in bank 1 that W_Temp is located in bank
0.  This way, we can always just refer to W_Temp, and be sure it will point
to *one* of our defined locations, no matter which bank we are in at the time.

This is, as Andy pointed out, very useful for temporary storage during
interrupt service routines (ISRs), since you don't really care *where* your
"scratchpad" area is, you just care that you can reach it without having to
worry about what bank you were in when the ISR got called.

- Rick "Jumping out now" Dickinson

+---------------------------------+---------------------------+
| Enterprise ArchiTechs Company   |"You can't reason someone  |
|     Lotus Certified Notes       |  out of a position they   |
|  Appl. Design & Administration  | didn't reason themselves  |
|(818)563-1061  rtdspamspam_OUTnotesguy.com  |  into" -- Rick Adams,     |
|   http://www.eArchiTechs.com    |   in alt.folklore.urban   |
+---------------------------------+---------------------------+

1998\03\11@070521 by Caisson

flavicon
face
Hello Calvin,

As you can see I assumed your question was about an
Interrupt-Service-Routine,
and will answer it accordingly.  (Maybe next time you could give us
pic-listers
some more information to work with ... Please :-)

Here is a routine I use in a PIC16C74A. It works like a charm.

;-----------------------------------------
;Because W-register is saved before the Bank-select bits are set for the
Interrupt-;routine the register-bank in wich the W-register is saved is
undetermined.
;therefore the Storage-register S_WReg exists in _ALL_ register-banks !

;- Save your W-register here.  It doesn't matter in what bank it will be
put,
;  because you will read it (at the end of this routine) from the same bank
 movwf S_WReg  ;Save W register
                       ;/ ! S_WReg exists in _ALL_ register-banks !

;- Now copy STATUS into W (without changing ANY status-flags !)
 swapf STATUS,W        ;Read Status register into W
;- Select the Register-bank you want to work in
 bcf   STATUS,RP0      ;/ Select Register-bank #0
 bcf   STATUS,RP1      ;/  ( <- This line is NOT needed in most of the PIC's)
;- Now store your STATUS-register in a Known register-bank
 movwf S_SReg  ;/

;- Save any register you'll want to use in your ISR
(Interrupt-Service-Routine).
 movf  FSR,W           ;Save FSR
 movwf S_FSR           ;/

; Do your interrupt-stuf here ! ...

;- Restore all save registers
 movf  S_FSR,W ;Restore FSR-register
 movwf FSR             ;/

;- Copy saved STATUS-register into W (Twice nibble-swapped gives origional)
 swapf S_SReg,W        ;Restore Status register
;- Store W into STATUS, thereby restoring Register-bank -flags
 movwf STATUS  ;/

;- Read saved W register from the register-bank you started with
 swapf S_WReg  ;Restore W register
 swapf S_WReg,W        ;/
;- Last but not least, return from interrupt :-)
 retfie

;-----------------------------------------

One last thing: Define your S_WReg as _first_ byte in free-usable RAM,
it'll make life that much easier ...

Greetz,
  Rudy Wieser















----------
> Van: TONY NIXON 54964 <@spam@Tony.nixonKILLspamspamENG.MONASH.EDU.AU>
> Aan: KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU
> Onderwerp: Re: Quick question...
> Datum: woensdag 11 maart 1998 2:03
>
> > How can I define a register (i.e. W_Temp) in several banks at the same
time?
{Quote hidden}

1998\03\11@074834 by Mark Lezama

flavicon
face
Lo unico que necesitas es definirlo en el primer banco y luego cuando cambies al
otro banco la direccion que deseas sera la misma pero en el otro banco. Quiero
decir, los bancos estan diferenciados por el bit RP0 en el registro de status
por lo cual la direccion 0x20 en el banco 0 se diferencia de la 0xA0 en el banco
1 solo en el bit mas significativo o RP0, el resto es igual.

0xA0 = 0x20 + 0x80

Mark Lezama

Calvin escribis:

> How can I define a register (i.e. W_Temp) in several banks at the same time?
>
> Calvin

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