Shop OBEX P1 Docs P2 Docs Learn Events
How does bank instruction really work in SX52's ???????? — Parallax Forums

How does bank instruction really work in SX52's ????????

sounddezignsounddezign Posts: 9
edited 2005-09-09 18:24 in General Discussion
Hi guys,

I'm after a proper explaination of how the bank instruction works in the SX52. The literature I've read is divided on whether the bank instruction fails to set bit.7 or bit.4 in the FSR.

The SX key manual says you have to manually set bit.4 in the FSR
The SX52 datasheet says its bit.7
most confusing is the· "Programming the SX microcontroller by Gunther Daubach" which at the beginning says that you must manually set bit.4 and then later goes on to give an example of a macro which sets bit7 as required!

Can somebody with experience of the sx52 please explain exactly what bits are changed in the FSR when the bank instruction is used.

Thanks

Andy

Comments

  • pjvpjv Posts: 1,903
    edited 2005-09-09 15:17
    Hi Andy;

    It's bit 7.

    Cheers,

    Peter (pjv)
  • BeanBean Posts: 8,129
    edited 2005-09-09 16:11
    Andy,
    I think the very 1st engineering samples of the SX48/52 used bit 4, but then it was changed to bit 7 in the production units.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012
    Product web site: www.sxvm.com
    Available soon!! Video overlay(OSD) module...

    "I'm a man, but I can change, if I have to, I guess"
    Red Green
    ·
  • David BDavid B Posts: 592
    edited 2005-09-09 16:32
    There is a document at http://www.parallax.com/dl/appnt/sx/An15Conv.pdf that briefly discusses the SX48/52 changes, including the changed bank operation and the need to set bit 7.

    I'm still confused about how to use the 16 bytes in SX48/52 variable-space bank 0.

    I'm used to issuing statements like:

    org $30
    bank_a = $
    var1 ds 1
    var2 ds 1

    and then in code, I do

    _bank bank_a
    mov var1, #0

    (using the bank macro that sets or clears bit 7)

    But it seems like this works for every SX48/52 bank EXCEPT bank 0.

    If I try to access var0:

    org $0
    bank_zero = $
    var0 ds 1

    _bank bank_zero
    mov var0, #0

    then var0 points to registers, not my variable.

    I guess that bank 0 of user variable space is not accessable for this sort of variable naming?

    Are there any tricks that make the 16 bank zero variables easier to use?

    David
  • BeanBean Posts: 8,129
    edited 2005-09-09 17:15
    When using banks all variables are really located in the range $10 to $1F when used in instructions like "MOV var1,#0"
    What the assembler does is any variables > $0F becomes $1x (with x being the lowest 4 bits).
    So "MOV $1F,#5" assembles to EXACTLY the same code as "MOV $2F,#5" or "MOV $3F,#5"

    Now if you use indirect addressing (FSR,IND), then $00 to $0F access the global variables.
    You CANNOT access bank 0 using indirect addressing (FSR,IND).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012
    Product web site: www.sxvm.com
    Available soon!! Video overlay(OSD) module...

    "I'm a man, but I can change, if I have to, I guess"
    Red Green
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-09-09 17:21
    David, look at pages 25-29 of the SX user manual. I think your code is attempting to use an addressing mode other than semi-direct to access bank 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-09-09 18:24
    David,

    you've got a lot of answers to the question in your very first post. Now , it's me, bailing in too.

    When I wrote in my book that you'll have to set/clear bit 4 "manually" - this indeed was correct for the first available SX48/52 engineering samples. Later it was changed to bit 7. Seems as if you have found another typo in my book. When I wrote the very first parts of the text, the engineering samples were the only I had for testing. Obviously, I forgot to change the text from bit 4 to 7 later. Sorry for that - I'll fix it in the next edition.

    BTW: I noticed that I actually wrote that the bit has to be set/cleared "manually". Beginners might be looking for a little toggle swich attached to the SX48/52 to change that bit, or even open the plastic package, searching for a toggle switch inside, soldered to the silicon - NO - NO - NO, don't do it - there is no switch smile.gif . I actually wanted do say that a separate CLRB/SETB instruction is necessary to handle that bit, or you use the macro shown later in the text (modifying the correct bit).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
Sign In or Register to comment.