Shop OBEX P1 Docs P2 Docs Learn Events
ASM - Pin Assignments ? — Parallax Forums

ASM - Pin Assignments ?

Areal PersonAreal Person Posts: 197
edited 2007-11-21 18:33 in Propeller 1
Hi,

I'm using·three ASM drivers that makes pin assignments at the bottom
area of each asm file.

They look like this...

FILE 1.
outs··· long· 7············· 'For pins P0 and P1 and P2 as out· (P2 is XLAT)
FILE 2.
outs··· long· 192·········· 'For pins P6 and P7 as out··

FILE 3.
outs··· long· 768···········'For pins P8 and P9 as out

QUESTION:

How does these lines of code work, I need to add a extra pin·XLAT (like the first does) to the second
and third lines. How do I figure this ?

What would the longs be if I needed this? ...

FILE 2.
outs··· long··????·········· 'For pins P6 and P7 and P8 as out (P8 is XLAT)··

FILE 3.
outs··· long··????···········'For pins P9 and P10 and P11 as out (P11 is XLAT)

I need to learn how to do it for myself as I may need to change pins.

But How does it work ??··Is there a standard formula I can use ?

Thanks for the help,
Areal




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have a tree growing out of my head, but

what do you expect ? I'm a programmer.

Post Edited (Areal Person) : 11/19/2007 4:32:57 PM GMT

Comments

  • hippyhippy Posts: 1,981
    edited 2007-11-19 16:59
    You probably want to visualise the numbers in the longs as binary and it should become much clearer ...

    '     111111
    '     54321098 76543210
    
    long %00000000_00000111  '  2,  1, 0  = 7
    long %00000000_11000000  '  7,  6     = 192
    long %00000011_00000000  '  9,  8     = 768
    
    
    



    To update to include your XLAT pin then it's a simple case of seteting the correct bit

    '     111111
    '     54321098 76543210
    
    long %00000000_00000111  '  2,  1, 0
    long %00000001_11000000  '  8,  7, 6
    long %00001110_00000000  ' 11, 10, 9
    
    
    



    Easier still ...

    long ( |< 2  ) | ( |< 1  ) | ( |< 0 )
    long ( |< 8  ) | ( |< 7  ) | ( |< 6 )
    long ( |< 11 ) | ( |< 10 ) | ( |< 9 )
    
    
    



    I have to admit it's a personal hate of mine when people take numbers which make sense in binary ( or hexadecimal ) and express those as decimal.

    Post Edited (hippy) : 11/19/2007 5:06:55 PM GMT
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-11-19 17:14
    > I have to admit it's a personal hate of mine when people take numbers which make sense in binary ( or hexadecimal ) and
    > express those as decimal.

    Called "magic numbers" and a bad habit for some programmers (and a reason to be fired).


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-19 17:33
    Thanks Hippy,

    That helped me out, but I'm still kinda lost...
    e.g...

    16········ 15···· 14···· 13···· 12··· 11··· 10··· 9···· 8·· 7··· 6·· 5· 4 3 2 1
    16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 18, 8, 4,2,1,0

    Thus...

    long %00000000_00000111 ' 2, 1, 0 = 7 How does it = 7 ?? I'm lost (2+1+0) = 3

    OR IS IT ??? ...
    ··················································································
    15········ 14···· 13···· 12···· 11··· 10····9····· 8····7···6··· 5·· 4· 3 2 1
    16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 18, 8, 4,2,1
    ····························································position······················· 2 1· 0
    long %00000000_00000111 ' 2, 1, 0 = 7 How does it = 7 ?? I'm lost (4+2+1) = 7

    What am I missing, I dont understand

    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.

    Post Edited (Areal Person) : 11/19/2007 5:47:08 PM GMT
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-11-19 17:44
    Areal Person said...
    16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 18, 8, 4,2,1· Thus...

    long %00000000_00000111 '·4+2+1 = 7
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-19 17:46
    Thanks !

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-11-19 21:22
    Areal, learn hexidecimal it's a convenient means for expressing short hand binary, once you learn the 16 values and their equivalent binary value you'll find construction of binary encoded constants second nature. You should not use the decimal value, because it always requires double checking to make sure you did the conversion correct, with hexidecimal each value corresponds to exactly 4 bits, each decimal digit represents 3.25 bits hence the complicated conversion process.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-20 20:38
    Ok, I'm making progress. I have a simple question..

    What does the #4 mean/do in the first line of this asm code ?
    Is it a pin assignmnt of p4 ? Or what ?

    {{........................................................}}
    mov t3,#4 wz ' Clock Pin
    muxnz outa,t3 ' Set XLAT Pin HIGH
    muxz outa,t3 ' Set XLAT Pin LOW
    {{........................................................}}

    Thanks,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • hippyhippy Posts: 1,981
    edited 2007-11-20 20:56
    mov t3,#4 wz

    Moves the constant value four to the variable named "t3" and clears the Z flag ( four is not zero )

    muxnz outa,t3 ' Set XLAT Pin HIGH

    Sets bit 2 of OUTA ( ie, Pin2 ) to !Z, makes it a one ( Z is zero )

    muxz outa,t3 ' Set XLAT Pin LOW

    Sets bit 2 of OUTA ( ie, Pin2 ) to Z, makes it a zero ( Z is zero )
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-20 21:13
    Ok,

    I went back and looked up muxnz.
    I dont understand how moving #4 into t3 can reference bit 2
    of outa.

    Is there a explanation ?

    I'm trying to move the XLAT·pin from pin 2 to pin P10

    Would I use mov t3,#20 wz··· ? Is that correct ?

    Is there an easy way to figure the constant needed ?

    Thanks for the help

    {{........................................................}}
    mov t3,#4 wz ' Clock Pin
    muxnz outa,t3 ' Set XLAT Pin HIGH
    muxz outa,t3 ' Set XLAT Pin LOW
    {{........................................................}}

    -Areal

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.

    Post Edited (Areal Person) : 11/20/2007 10:08:38 PM GMT
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-20 22:08
    bump. [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • hippyhippy Posts: 1,981
    edited 2007-11-21 00:29
    Areal Person said...
    I dont understand how moving #4 into t3 can reference bit 2
    of outa.

    Is there a explanation ?

    Yes, we're back to binary again ...

    Bit Values                 .------ 16
                               |.----- 8
                               ||.---- 4
                               |||.--- 2
                               ||||.-- 1
                               |||||
    Bit mask   :  %00000000_00000100 = 4
                                 |
                   111111        |
    Pin Number :   54321098 76543210
    
    
    



    No offence, but your signature doesn't seem to be very accurate ? Not the tree reference, that bit about being a programmer.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-11-21 01:05
    2 to the power of

    0,1,2,3, 4, 5, 6,· 7,· 8,· 9,· 10,· 11,· 12,· 13,·· 14,·· 15 (from memory) is:
    1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768

    every programmer should have at least the first 11 values memorized and should be able to recite the first 8 forwards or backwards.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-21 01:18
    smile.gif Some have difficulties with 2**15... It's something 32XXX; memory hook: XXX is the least sensible combination of 6,7, and 8: It starts neither with the highest digit (8) nor with the lowest (6), there is no adjacent combination (6,7 or 7,8)

    Also to be memorized :
    2**10 is around 1000 (1k)
    2*20 is around a million (1M)
    2*30 is around a billion (1G)
    2*32 is around 4 billion

    4 billion devided by 80 million = 50
  • Areal PersonAreal Person Posts: 197
    edited 2007-11-21 15:42
    I'm sorry for my Confusion, I’m working alone, and this is my first electronics
    project ever, it’s also the first time I have ever worked with a MCU.

    It’s a very important project, as my job depends on it. (I don’t really know
    how I got myself into this problem.)

    I do program, but at a higher aplication level (Transaction level, abstraction design etc...).

    I just wanted to say thank you to Mr. Hippy and to everyone else
    for helping me with this very much.

    I promise I will do my best in the future not to abuse the privilege of asking basic questions that I should know. I’m under allot pressure to perform.

    Again, Thank you very much, I hope everyone has a Happy Thanksgiving and eat lot's of Turkey [noparse]:)[/noparse]

    -Mark (aka Areal Person)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I have a tree growing out of my head, but

    what do you expect ? I'm a programmer.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-11-21 16:16
    Mark, don't worry about the questions. The only requirement here is a browser and interest.
  • hippyhippy Posts: 1,981
    edited 2007-11-21 17:15
    Areal Person said...
    I just wanted to say thank you to Mr. Hippy and to everyone else
    for helping me with this very much.

    You're welcome and do ask. I doubt I could do what you do best, so I was a bit harsh. Happy thanksgiving - we don't do that here in the UK, have to wait a full month before we get Turkey and all the trimmings smile.gif
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-11-21 18:33
    Areal, don't worry about the questions, keep them coming. We are just pointing out areas that you should become more familiar with in order to improve your coding skills and understanding.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.