Shop OBEX P1 Docs P2 Docs Learn Events
Value in BS2 emulator Shiftout? — Parallax Forums

Value in BS2 emulator Shiftout?

SRLMSRLM Posts: 5,045
edited 2008-11-11 16:49 in Propeller 1
Hi, can anyone tell me what the parameter of value does in the following code? My guess is that it tells when to write the data (clock high or low), but I'm not sure.

PUB SHIFTOUT (Dpin, Cpin, Value, Mode, Bits)| bitNum
{{
   Shift data out, master clock, for mode use ObjName#LSBFIRST, #MSBFIRST
   Clock rate is ~16Kbps.  Use at 80MHz only is recommended.
     BS2.SHIFTOUT(5,6,"B",BS2#LSBFIRST,8)
}}
    outa[noparse][[/noparse]Dpin]:=0                                          ' Data pin = 0
    dira[noparse][[/noparse]Dpin]~~                                           ' Set data as output
    outa[noparse][[/noparse]Cpin]:=0
    dira[noparse][[/noparse]Cpin]~~
    If Mode == LSBFIRST                                    ' Send LSB first    
       REPEAT Bits
          outa[noparse][[/noparse]Dpin] := Value                              ' Set output
          Value := Value >> 1                              ' Shift value right
          !outa[noparse][[/noparse]Cpin]                                      ' cycle clock
          !outa[noparse][[/noparse]Cpin]
          waitcnt(1000 + cnt)                              ' delay
    elseIf Mode == MSBFIRST                                ' Send MSB first               
       REPEAT Bits                                                                
          outa[noparse][[/noparse]Dpin] := Value >> (bits-1)                  ' Set output           
          Value := Value << 1                              ' Shift value right    
          !outa[noparse][[/noparse]Cpin]                                      ' cycle clock          
          !outa[noparse][[/noparse]Cpin]                                                             
          waitcnt(1000 + cnt)                              ' delay                
    outa[noparse][[/noparse]Dpin]~                                            ' Set data to low
 

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-11-11 14:14
    Hello SRLM,

    no it is the datavalue that will be sended out as a serial bitstream

    best regards

    Stefan
  • SRLMSRLM Posts: 5,045
    edited 2008-11-11 16:49
    Ah. I'm not sure what I was thinking. Of course I need to output some sort of data with a Shiftout. Thank you.
Sign In or Register to comment.