HELP 74LV8153N Shitft register ,can anyone give me code ???
Hi there , ive been fooling around some time to get this 74lv8153 shift register working over 1 wire so I can save some pin's.
thout I had a working program but i lost it and it didn't work well
can anyone please help me with some sample code on how to get the
data in the shift register,
2start bit+ 3 Adress bits + 4 data bits + 1stop bit
sending this string twice should get the data in but i can't get it working right
please some help ,
if the codet can read let say from a data file how to set the outputstates would be great *** thats what I finally need, or just a good control of the shift register
hope to hear something
igor
thout I had a working program but i lost it and it didn't work well
can anyone please help me with some sample code on how to get the
data in the shift register,
2start bit+ 3 Adress bits + 4 data bits + 1stop bit
sending this string twice should get the data in but i can't get it working right
please some help ,
if the codet can read let say from a data file how to set the outputstates would be great *** thats what I finally need, or just a good control of the shift register
hope to hear something
igor

Comments
As it is standard RS232 serial to parallel.
You can use any of Serial RS232 driver in OBX
Here is apossible send methode (untested):
CON TxPin = 0 ' set your out pin here BitTime = 80_000_000 / 19200 PUB Send(addr,value) : txByte | t txByte := %11_0000_000_10_1_0000_000_10 ' set start-stop bits txByte |= addr<<2 | addr<< 12 ' add address (0..7) txByte |= (value & $0F) << 5 ' add low nibble txByte |= (value & $F0) << 11 ' add high nibble t := cnt ' sync repeat 21 ' 20 bits in total + stop waitcnt(t += BitTime) ' wait bit time outa[TxPin] := (txByte >>= 1) ' output bitsAndy
Serial data sends the low bit first (immediately after the start bit). The protocol of the 74xx8153 requires 2 start bits, 7 data bits and 1 stop bits, two characters. However, the 2 start bits is a misnomer because they require the second start bit to be a "1" not a "0". Therefore, what they really mean is 1 start bit "0" followed by the lowest bit (must always be "1") followed by a0, a1, a2 as the address bits (determined by the hardware pins), followed by d0, d1, d2, d3 of the low nibble of the latch contents you require to set, followed by a stop bit ("1"). The next character is start "0" followed by a "1" followed by a0, a1, a2 again, and then data bits d4, d5, d6, d7 of the high nibble of the latch contents you require to set and stop bit..
So, your 2 characters (bytes) to be sent are...
%d3, d2, d1, d0, a2, a1, a0, "1"
%d7, d6, d5, d4, a2, a1, a0, "1"
I hope this makes sense.
The first byte is made up of %1aaallll where aaa=the address pins, and llll (LLLL) = low nibble. The second byte is %1aaauuu where uuuu = the upper nibble. Configure to send at 24,000 baud or less (19,200 would be a good choice).
i did somthing like this
CON TxPin = 23 ' set your out pin here BitTime = 80_000_000 / 19200 _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ ss : "simple_serial" PUB main : txByte | t dira[23]~~ outa[23]~~ repeat send(000,%01010101) PUB Send(addr,value) : txByte | t txByte := %11_0000_000_10_1_0000_000_10 ' set start-stop bits txByte |= addr<<2 | addr<< 12 ' add address (0..7) txByte |= (value & $0F) << 5 ' add low nibble txByte |= (value & $F0) << 11 ' add high nibble t := cnt ' sync repeat 21 ' 20 bits in total + stop waitcnt(t += BitTime) ' wait bit time outa[TxPin] := (txByte >>= 1) ' output bitsbut it ai't working
please help me as im sure that im overlookig somthing
You don't need to include the simple_serial object. But this is not the problem.
There was a little error in the send routine: the bits are shifted before first bit output.
Try this one:
CON TxPin = 23 ' set your out pin here BitTime = 80_000_000 / 19200 _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 PUB main dira[TxPin]~~ outa[TxPin]~~ repeat send(%000,%01010101) waitcnt(clkfreq/20 + cnt) ' a short pause for better scope trigger PUB Send(addr,value) : txByte | t txByte := %11_0000_000_10_1_0000_000_10 ' set start-stop bits txByte |= addr<<2 | addr<< 12 ' add address (0..7) txByte |= (value & $0F) << 5 ' add low nibble txByte |= (value & $F0) << 11 ' add high nibble t := cnt ' sync repeat 21 ' 20 bits in total + stop waitcnt(t += BitTime) ' wait bit time outa[TxPin] := txByte ' output bit txByte >>= 1 ' next bitAndy