Value in BS2 emulator Shiftout?
SRLM
Posts: 5,045
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
no it is the datavalue that will be sended out as a serial bitstream
best regards
Stefan