Shop OBEX P1 Docs P2 Docs Learn Events
HELP 74LV8153N Shitft register ,can anyone give me code ??? — Parallax Forums

HELP 74LV8153N Shitft register ,can anyone give me code ???

Igor_RastIgor_Rast Posts: 357
edited 2011-08-16 11:57 in Propeller 1
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

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2011-08-11 05:42
    Hi.

    As it is standard RS232 serial to parallel.
    You can use any of Serial RS232 driver in OBX

    Igor_Rast wrote: »
    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
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-11 15:20
    Remember, the serial is really 1 start bit plus the first data bit=1 (the docs say 2 start bits, first 0 then 1, which is a little confusing to those who really do not know much about serial).
  • AribaAriba Posts: 2,690
    edited 2011-08-11 16:18
    You can change the TX methode of the Simple_Serial a bit to output 20 bits. This needs no additional cog, and allows baudrates up to ~19.2 kBaud.

    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 bits  
    

    Andy
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-08-11 20:33
    Perhaps I did not make my reply clear. You can use any of the serial drivers without modification. You just send two 8bit bytes as the serial driver normally would.

    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).
  • Igor_RastIgor_Rast Posts: 357
    edited 2011-08-15 17:46
    thnx for your reply's but im trying your pice of code but can't get it working

    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 bits
    
    


    but it ai't working
    please help me as im sure that im overlookig somthing
  • AribaAriba Posts: 2,690
    edited 2011-08-15 18:35
    igor

    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 bit
    

    Andy
  • Igor_RastIgor_Rast Posts: 357
    edited 2011-08-16 11:57
    Thnx Andy , it Work's now > thanks allot
Sign In or Register to comment.