Shop OBEX P1 Docs P2 Docs Learn Events
Using Shift-Out from SX28 to Shift-In on SX48 — Parallax Forums

Using Shift-Out from SX28 to Shift-In on SX48

John BondJohn Bond Posts: 369
edited 2007-02-09 13:24 in General Discussion
Hi Guys
·
PLEASE HELP!!!
·
I am trying to pass a byte from an SX28 to an SX48 development board using the Shift-Out and Shift-In commands. I can’t get it to work.
·
What am I doing wrong…
·
·
From>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
·
Dpin·········· VAR···· RA.0·········· ' shift data
Cpin·········· VAR···· RA.1·········· ' shift clock
Latch········· VAR···· RA.2·········· ' latch outputs
LED······ ··· ·VAR· RB.0
·
temp1········· VAR···· Byte
ShiftChar····· VAR···· Byte
·
watch counter, 8, udec
·
' ====================================================
· PROGRAM Start
' ====================================================
·
'

' Subroutine Declarations
'

ShiftItOut········· SUB···· 1········ ' pass value out
·
Start:
ShiftChar = 123
·
TRIS_B = %00000000
·
Main:
·
··· ShiftItout ShiftChar ···' transfer data
break··································
·
·
···· toggle LED
···· pause 20
·
GOTO main
·
·
ShiftItout:
· temp1 = __PARAM1····· ··········' capture value
· SHIFTOUT Dpin, Cpin, 0, temp1·· ' send the bits
· PULSOUT Latch, 2·············· ·' transfer to outputs
· RETURN
·
·


·
To>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DEVICE········· SX48, OSC4MHZ,
FREQ··········· 4_000_000
·
·
Dpin··········· VAR···· RA.1····· ' shift data
Cpin··········· VAR···· RA.2····· ' shift clock
Latch·········· VAR···· RA.3····· ' latch outputs
·
temp1·········· VAR···· Byte
·
·
watch temp1, 8, udec
·
' ===================================================
· PROGRAM Start
' ===================================================\
Start:
·
TRIS_A = %11111111
·
Main:
·
SHIFTIN DPin, CPin, 0, temp1
break··································
·
GOTO main

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-09 09:24
    Your shiftIn code must act as slave, that is it must receive the clock,
    not generate the clock. The clock is generated by the shiftOut.
    The SX/B shiftIn is only master. You probably need a VP written in assembly,
    but perhaps someone has a SX/B version of a SPI slave.

    Go to
    http://www.sxlist.com/techref/ubicom/virtperf.htm
    and scroll down to SX to SX spi interface

    regards peter
  • John BondJohn Bond Posts: 369
    edited 2007-02-09 09:48
    Thanks Peter - That article makes it clear

    So my options seem to be:
    - Get a slave spi or write one (I'm not keen to write one, i also only work in SX/B)
    - Use a UART (seems overkill for 1 byte)
    - Write my own proprietry shift register

    Kind regards from the Dark Continent

    John Bond

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • BeanBean Posts: 8,129
    edited 2007-02-09 12:20
    John,
    Just send the value using SEROUT and SERIN instead of SHIFTOUT and SHIFTIN.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
  • John BondJohn Bond Posts: 369
    edited 2007-02-09 13:24
    Thanks Bean

    - That also means wne the system expands, I can have a single sender and many receivers and use 2 bytes, 1 to identify the address and the 2nd as the control byte...

    You know, I am fast asleep today.

    John Bond

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.