Shop OBEX P1 Docs P2 Docs Learn Events
Stampworks experiment #23 used with App II — Parallax Forums

Stampworks experiment #23 used with App II

ArchiverArchiver Posts: 46,084
edited 2001-10-23 14:42 in General Discussion
Hi Al(l),
I was trying to get familiar with Shiftout and Shiftin commands. I
thought experiment #23 was a good example to work with. The 74x595
was hooked up to the App-II (which is a programmed PIC16F873) instead
of the BS2. I have attached two basic codes (the one with the "a" in
the end is the orginal from stampworks). The LED flashes only forward
and doesn't flash backwards. Why is that happening? Any response will
be appreciated.

Here's the code from exp #23:
'
======================================================================
===
' File: 74x595.BS2
'
' Use three lines to control eight with a 74x595 shift register
'
======================================================================
===
D_out CON 0 ' serial out (74x595.14)
Clock CON 1 ' shift clock (74x595.11)
Latch CON 2 ' output latch (74x595.12)
DlyTm CON 100
pattern VAR Byte ' output pattern
'

Initialize:
LOW Latch ' make output and keep low
pattern = %00000001
'

GoForward:
GOSUB Out595
PAUSE DlyTm ' put pattern on 74x595
pattern = pattern << 1 ' shift pattern to the left
IF pattern = %10000000 THEN GoReverse ' test for final position
GOTO GoForward ' continue in this direction
GoReverse:
GOSUB Out595
PAUSE DlyTm
pattern = pattern >> 1
IF pattern = %00000001 THEN GoForward
GOTO GoReverse
END
'

Out595:
SHIFTOUT D_out,Clock,MSBFirst,[noparse][[/noparse]pattern] ' send pattern to 74x595
PULSOUT Latch,3 ' latch outputs
RETURN

Here's the how I modified the code to take up the upper 3 pins of the
PIC:

'
======================================================================
===
' File: 74x595.BS2
'
' Use three lines to control eight with a 74x595 shift register
'
======================================================================
===

INCLUDE "modedefs.bas"

D_out CON 5 ' serial out (74x595.14)
Clock CON 6 ' shift clock (74x595.11)
Latch CON 7 ' output latch (74x595.12)
DlyTm CON 500
pattern VAR BYTE ' output pattern
'

Initialize:
Low Latch ' make output and keep low
pattern = %00000001
'

GoForward:
GoSub Out595
Pause DlyTm ' put pattern on 74x595
pattern = pattern << 1 ' shift pattern to the left
IF pattern = %10000000 Then GoReverse ' test for final position
GoTo GoForward ' continue in this direction

GoReverse:
GoSub Out595
Pause DlyTm
pattern = pattern >> 1
IF pattern = %00000001 Then GoForward
GoTo GoReverse

End
'

Out595:
ShiftOut D_out,Clock,MSBFirst,[noparse][[/noparse]pattern] ' send pattern to 74x595
'ShiftOut PORTB.0,PORTB.1,MSBFirst,[noparse][[/noparse]pattern]
PulsOut Latch,10 ' latch outputs
Return


Sincerely,
RP

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-10-23 14:42
    Hi Al(l),
    I was trying to get familiar with Shiftout and Shiftin commands. I
    thought experiment #23 was a good example to work with. The 74x595
    was hooked up to the App-II (which is a programmed PIC16F873) instead
    of the BS2. For those not familiar with the App-II, it can be found
    at this site: www.al-williams.com/awce/app2.htm. The first code is
    the original code. The second was modified to be compiled by Pic
    Basic Pro. The LED flashes only forward and doesn't flash backwards.
    Why is that happening? Any response will
    be appreciated.

    Here's the code from exp #23:
    '
    ======================================================================
    ===
    ' File: 74x595.BS2
    '
    ' Use three lines to control eight with a 74x595 shift register
    '
    ======================================================================
    ===
    D_out CON 0 ' serial out (74x595.14)
    Clock CON 1 ' shift clock (74x595.11)
    Latch CON 2 ' output latch (74x595.12)
    DlyTm CON 100
    pattern VAR Byte ' output pattern
    '

    Initialize:
    LOW Latch ' make output and keep low
    pattern = %00000001
    '

    GoForward:
    GOSUB Out595
    PAUSE DlyTm ' put pattern on 74x595
    pattern = pattern << 1 ' shift pattern to the left
    IF pattern = %10000000 THEN GoReverse ' test for final position
    GOTO GoForward ' continue in this direction
    GoReverse:
    GOSUB Out595
    PAUSE DlyTm
    pattern = pattern >> 1
    IF pattern = %00000001 THEN GoForward
    GOTO GoReverse
    END
    '

    Out595:
    SHIFTOUT D_out,Clock,MSBFirst,[noparse][[/noparse]pattern] ' send pattern to 74x595
    PULSOUT Latch,3 ' latch outputs
    RETURN

    Here's the how I modified the code to take up the upper 3 pins of the
    PIC:

    '
    ======================================================================
    ===
    ' File: 74x595.BS2
    '
    ' Use three lines to control eight with a 74x595 shift register
    '
    ======================================================================
    ===

    INCLUDE "modedefs.bas"

    D_out CON 5 ' serial out (74x595.14)
    Clock CON 6 ' shift clock (74x595.11)
    Latch CON 7 ' output latch (74x595.12)
    DlyTm CON 500
    pattern VAR BYTE ' output pattern
    '

    Initialize:
    Low Latch ' make output and keep low
    pattern = %00000001
    '

    GoForward:
    GoSub Out595
    Pause DlyTm ' put pattern on 74x595
    pattern = pattern << 1 ' shift pattern to the left
    IF pattern = %10000000 Then GoReverse ' test for final position
    GoTo GoForward ' continue in this direction

    GoReverse:
    GoSub Out595
    Pause DlyTm
    pattern = pattern >> 1
    IF pattern = %00000001 Then GoForward
    GoTo GoReverse

    End
    '

    Out595:
    ShiftOut D_out,Clock,MSBFirst,[noparse][[/noparse]pattern] ' send pattern to 74x595
    'ShiftOut PORTB.0,PORTB.1,MSBFirst,[noparse][[/noparse]pattern]
    PulsOut Latch,10 ' latch outputs
    Return


    Sincerely,
    RP
Sign In or Register to comment.