Shop OBEX P1 Docs P2 Docs Learn Events
P2: pin output question — Parallax Forums

P2: pin output question

potatoheadpotatohead Posts: 10,261
edited 2012-12-16 23:32 in Propeller 1
Here is a short program that writes the counter to some of the output pins with LED's attached on the DE2 board. Edited because I pasted the wrong code. Sorry. Here are the correct programs:
' Terasic DE2-115 Prop2 LED Blinker
' ------------------------------------
' This one is broken, and I don't know why
DAT
                org

                neg     dirb, #1        'make the port B I/Os outputs
                
:loop           getcnt  A               'fetch lower 32 bits of global counter
                shr     A, #16          'shift away the fast incrementing digits
                and     A, outmask      'zero lower bits
                mov     pinb, A         'write slow ones to LED's on DE2 board

                jmp     #:loop          'keep doing it!


A               res     1               'storage
B               res     1
outmask         long    $00_00_FF_00    'write higher bits only



' Terasic DE2-115 Prop2 LED Blinker
' ------------------------------------
' This one works!
DAT
                org

                neg     dirb, #1        'make the port B I/Os outputs
                
:loop           getcnt  A               'fetch lower 32 bits of global counter
                shr     A, #24          'shift away the fast incrementing digits
                shl     A, #8
                mov     pinb, A         'write slow ones to LED's on DE2 board

                jmp     #:loop          'keep doing it!


A               res     1               'storage

What am I missing here? No combination of AND appeared to work for me. ??? I tried making the outmask value all ones too.

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-12-16 21:57
    potatohead wrote: »
    A               res     1               'storage
    outmask         long    $00_00_00_FF    'write higher bits only
    
    res-before-long?
  • potatoheadpotatohead Posts: 10,261
    edited 2012-12-16 21:59
    Yes. Thanks! Haven't made that one in a while and I totally couldn't see it. Appreciated!
  • SapiehaSapieha Posts: 2,964
    edited 2012-12-16 22:41
    Hi

    Why not use this that way
    000011 001 1 CCCC nnnnnnnnn 011001010        SETF    #n      'Configure field mover with 0..511 1
    
                    neg     dirb, #1        'make the port B I/Os outputs
                    SETF    #XX       'Configure field mover with D      1
    
    
    000101 000 0 CCCC DDDDDDDDD SSSSSSSSS        MOVF    D,S     'Move field from S into D          1
    
    instead of
    
                    shr     A, #16          'shift away the fast incrementing digits
                    and     A, outmask      'zero lower bits
                    mov     pinb, A         'write slow ones to LED's on DE2 board
    
    

    potatohead wrote: »
    Yes. Thanks! Haven't made that one in a while and I totally couldn't see it. Appreciated!
  • potatoheadpotatohead Posts: 10,261
    edited 2012-12-16 23:32
    Because I was just doing a simple program as an example for the monitor documentation I'm working on. Honestly, I wanted it to be more than 16 bytes of object code. I appreciate your suggestion.
Sign In or Register to comment.