Shop OBEX P1 Docs P2 Docs Learn Events
slow spin — Parallax Forums

slow spin

mctriviamctrivia Posts: 3,772
edited 2009-01-21 04:48 in Propeller 1
I have built a 60x14 led display(840 pixels) with the following code there is a visible blink.

  dira[noparse][[/noparse]25..16]~~
  repeat
    repeat ubVb from 0 to 13
      outa[noparse][[/noparse]25..22]:=ubVb
      Multi:=1<<ubVb
      repeat ubVa from 0 to 59
        if Long[noparse][[/noparse]@ulDisplay][noparse][[/noparse]ubVa]&Multi
          outa[noparse][[/noparse]21..16]:=ubVa
        else
          outa[noparse][[/noparse]21..16]:=$3F  




my math says 80MHz/60/840=1587 cycles per pixel to not blink. cant figure out how the interpreter could be that slow

Comments

  • AleAle Posts: 2,363
    edited 2009-01-20 09:05
    The interpreter uses around 80 cycles per opcode.

    I'd recommend you use assembly for that or you split it across two COGs (with SPIN) but you may need to rewire part of your matrix. Asm is the way to go smile.gif
  • hal2000hal2000 Posts: 66
    edited 2009-01-20 16:28
    ALE·is right.

    ASM is the solution
    Spin is·slow
    Spin control is useful for processes that do not need speed

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Does the curiosity killed the cat?
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-21 01:09
    i seem to be having some trouble with the converting to ASM. I think I am making an error with the pointerX but not sure. wish we could use index reads.

    DAT
    ulDisplay long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    
    
    DAT
                  org       0
                   
                  'Set Direction
    Display       mov       dira,#PINSDIR
    
                  'Set to begining of dislay
    :main         mov       ulY,#0                  'zero ulY
    
                  'Initialize output to start processing row
    :outer        mov       temp,ulY                'copy to temp
                  shl       temp,22                 'rotate to match output pins
                  or        temp,#LEDOFF            'turn all leds off
                  mov       outa,temp               'set output pins
    
                  'Set to begining of row
                  mov       ulX,#0                  'Set to first pixel of row
                  mov       ptrToX,#ptrToDisplay     'copy display pointer
    
                  'Calculate pixel mask
                  mov       ulM,#1                  'Set ulM to 1
                  shl       ulM,ulY                 'Shift left to proper bit                    '
    
                  'Calculate if pixel is on or off
    :inner        rdlong    temp,ptrToX
                  and       temp,ulM
                  cmp       temp,#0 WZ
    
                  'Calculate output state
                  mov       temp,ulX
                  shl       temp,16
            if_z  mov       outa,#LEDOFF            'turn led off                
            if_nz or        outa,temp               'turn led on
    
                  'Set for next pixel
                  add       ulX,#1
                  add       ptrToX,#1
    
                  'See if finished line
                  cmp       ulX,#60 WZ
            if_nz jmp       #:inner
    
                  'See if finished display
                  add       ulY,#1
                  cmp       ulY,#14 WZ
            if_nz jmp       #:outer
                  jmp       #:main             
    
    
    'Locale Time Value
    ulX           long      0
    ulY           long      0
    ulM           long      0
    ptrToDisplay  long      0
    ptrToX        long      0
    temp          long      0  
    
    'constants
    LEDOFF        long      $003F0000
    PINSDIR       long      $03FF0000
                  fit       496  
    
    
  • KyeKye Posts: 2,200
    edited 2009-01-21 03:47
    Okay, first #pinsdir produces the address of the variable, not the stuff in the variable, the same goes for the use of #Ledoff. Just use the name only to acess the stuff in the variable.

    This problem is also present with #ptrToDisplay which again produces the address of the register in the cog's rams, not the stuff in the address.

    Those are the biggest flaws I see in the code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,

    Post Edited (Kye) : 1/21/2009 3:52:58 AM GMT
  • mctriviamctrivia Posts: 3,772
    edited 2009-01-21 04:48
    i figuered out I had # n wrong places. # is used to read address of that variable or emediate value. I have fixed those errors below but it still does not work. Now for some reason every 4 pixels horizontally are identical to each other. asm did fix blinking image is solid.

    DAT
                  org       0
                   
                  'Set Direction
    Display       mov       dira,PINSDIR
    
                  'Set to begining of dislay
    :main         mov       ulY,#0                  'zero ulY
    
                  'Initialize output to start processing row
    :outer        mov       ulLineMask,ulY          'copy to temp
                  shl       ulLineMask,#22          'rotate to match output pins
                  
                  'Set to begining of row
                  mov       ulX,#0                  'Set to first pixel of row
                  mov       ptrToX,ptrToDisplay     'copy display pointer
    
                  'Calculate pixel mask
                  mov       ulM,#1                  'Set ulM to 1
                  shl       ulM,ulY                 'Shift left to proper bit                    '
    
                  'Calculate if pixel is on or off
    :inner        rdlong    temp,ptrToX
                  and       temp,ulM
                  cmp       temp,#0 WZ
    
                  'Calculate output state
                  mov       temp,ulX                'Copy current X value
                  shl       temp,#16                'Shift X value to align with output pins
                  or        temp,ulLineMask         'Add Y portion
            if_z  mov       outa,LEDOFF             'turn led off                
            if_nz mov       outa,temp               'turn led on
    
                  'Set for next pixel
                  add       ulX,#1
                  add       ptrToX,#1
    
    
    
                  'See if finished line
                  cmp       ulX,#60 WZ
            if_nz jmp       #:inner
            
                  'See if finished display
                  add       ulY,#1
                  cmp       ulY,#14 WZ
            if_nz jmp       #:outer
                  jmp       #:main
                              
    
                      
    
    'Locale Time Value
    ulX           long      0
    ulY           long      0
    ulM           long      0
    ptrToDisplay  long      0
    ptrToX        long      0
    temp          long      0
    ulLineMask    long      0 
    
    'constants                        
    LEDOFF        long      $003F0000
    PINSDIR       long      $03FF0000
                  fit       496    
    
    
Sign In or Register to comment.