Shop OBEX P1 Docs P2 Docs Learn Events
Breaking down 32 output's into 4 separate ports — Parallax Forums

Breaking down 32 output's into 4 separate ports

Brian_BBrian_B Posts: 842
edited 2008-07-29 12:30 in Propeller 1
Hi,
·I've been playing around with a keyboard scan routine for some time now . Say you break up the 32 outputs into 4 separate sections , say 0..7 port one,· 8..15 port two, ect . I'm trying to make out0 high then shift left to out1 , I don't want to go any further than out7 and I want to start over again.

·I have experimented with using TEST , CMP and MAX·but It's seems like I end up with alot of extra code. Is there a simple way to JMP back to out0 after shift left reaches out7 ?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank's Brian



·"Imagination is more important than knowledge..." ·· Albert Einstein

www.PropelX.com

www.NorthStarMachining.com

Comments

  • sstandfastsstandfast Posts: 39
    edited 2008-07-29 01:33
    Let me see if I understand exactally what you want to do. You want to count 0, 1, 2, 4, 8, 16, 32, 64, 128 and then back to 0 or back to 1? I also assume that you do not want your operations to effect the other three ports correct? A little more information please.

    Shawn
  • Brian_BBrian_B Posts: 842
    edited 2008-07-29 02:24
    Yes, 1 of the eight pins is "on" at any given time . %00000001 ,%00000010, %00000100 ,ect. Here is a modified version of one of Beau's sample programs that I'm using it·to test the results on a video screen. This version has a little bug, It hanges on bit 7 twice as long as the others.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank's Brian



    ·"Imagination is more important than knowledge..." ·· Albert Einstein

    www.PropelX.com

    www.NorthStarMachining.com






    Post Edited (Brian Beckius) : 7/29/2008 2:30:18 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2008-07-29 05:42
    Brian Beckius,

    I just·tested this with the demo board LED's, and it appears to do what I think you want it to do.

    CON
      _clkmode = xtal1 +pll16x
      _xinfreq =  5_000_000
    PUB Shift_Test
        cognew(@ShiftTest, 0) 
        repeat
     
    DAT
                  org       0
    ShiftTest
                  mov       LEDs_OUT,               #%00000001
                  shl       LEDs_OUT,               #16
                  mov       LEDs_DIR,               #%11111111
                  shl       LEDs_DIR,               #16
                  mov       dira,                   LEDs_DIR
    
                  mov       time,                   cnt
                  add       time,                   delay
    MainLoop
                  waitcnt   time,                   delay
     
                  cmp       LEDs_OUT,               Limit   wc
           if_c   shl       LEDs_OUT,               #1
           if_nc  shr       LEDs_OUT,               #7
     
                  mov       outa,                   LEDs_OUT
     
                  jmp       #MainLoop                    
     
    Limit         long      %00000000_10000000_00000000_00000000
    delay         long      40_000_000
     
    LEDs_OUT      res       1
    LEDs_DIR      res       1
    time          res       1
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Brian_BBrian_B Posts: 842
    edited 2008-07-29 12:30
    Perfect Beau !
    Now that opens the door up to having cog1 shifting 0..7 cog2 shifting 8..15 ,cog3 shifting 16..23 and cog4 shifting 24..31 ( I don't need the code for that, now that you have me over the hump).

    Is adding delay to the time just to be safe ? I see in a lot of sample programs that only add $FF to the time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Thank's Brian



    ·"Imagination is more important than knowledge..." ·· Albert Einstein

    www.PropelX.com

    www.NorthStarMachining.com
Sign In or Register to comment.