2x16 LCD on propeller

Hello everybody,
i want to use an old LCD with a propeller chip...
it has two 74HC595N shift registers...
it needs 5 cables:
1)Ground
2)+5V
3)STCLK
4)SHCLK
5)DS

using a modified version of the 74HC595_Regular in the obex it works fine only with backlight ( pin 0 )
VAR
    long ShiftData 
    long ClockPin
    long LatchPin
    long DataPin

PUB init(clock_pin, latch_pin, data_pin)
    ' Where are the pins?
    ClockPin := clock_pin
    LatchPin := latch_pin
    DataPin  := data_pin
    cognew(@init_asm, @ShiftData) ' Run the assembler code and save stack to ShiftData

PUB Out(data) ' Do the Shift
    ShiftData := data

PUB Last ' What did I shift?
    return ShiftData

PUB DataPtr ' Return a pointer to ShiftData
  return @ShiftData

PUB Invert(bit_pos) ' Invert xth bit
    ShiftData ^= (1 << bit_pos)

PUB High(bit_pos) ' Shift xth to high
    ShiftData |= (1 << bit_pos)

PUB Low(bit_pos)  ' Shift xth to low
    ShiftData &= !(1 << bit_pos)
    
PUB SetBit(bit_pos, state) ' Shortcut to shift the pins
    case state
        -1:
            Low(bit_pos)
        0:
            Invert(bit_pos)
        1: 
            High(bit_pos)

DAT
    org       0
init_asm
    mov       t1, par
    add       t1, #4                  ' Go to clock pin input
    rdlong    t2, t1                  ' Get clock pin
    mov       srclk, #1               ' Prepare srclk mask
    shl       srclk, t2               ' Move srclk mask into position
    add       t1, #4                  ' Go to latch pin input
    rdlong    t2, t1                  ' Get latch pin
    mov       srlatch, #1             ' Prepare srlatch mask
    shl       srlatch, t2             ' Move srlatch bit into position 
    add       t1, #4                  ' Go to data pin input
    rdlong    t2, t1                  ' Get data pin
    mov       srdata, #1              ' Prepare srdata mask
    shl       srdata, t2              ' Move srdata bit into position
    'Set the direction bits for the pins.
    or        dira, srclk
    or        dira, srlatch
    or        dira, srdata
    ' muxnz is used to flip the bits
    mov       t1, #0  wz
    muxnz     outa, srclk             ' Clock starts low
do_loop
    rdlong    val, par                ' Get value to shift out.
    muxnz     outa, srlatch           ' Latch starts low
    mov       count, #32              ' Shift 32 bits            
shift_bit
    shl       val, #1 wc              ' Consume a bit from val; store it in carry flag
    muxnz     outa, srclk             ' Make clock low
    muxc      outa, srdata            ' Output the consumed bit to the shift register
    nop                               
    muxz      outa, srclk             ' Clock high to latch bit of data
    djnz      count, #shift_bit       ' Do next bit
    muxz      outa, srlatch           ' Latch the data output
    jmp       #do_loop                ' Do it all over again. 

val     res   1
srclk   res   1
srlatch res   1
srdata  res   1
bit     res   1
t1      res   1        
t2      res   1
count   res   1

I just added the possibilty to invert a bit ( a simple xor, nothing difficult ) and modified the SetBit function to handle the invert bit...
how could i send some characters to the lcd?
Tagged:

Comments

  • 7 Comments sorted by Votes Date Added
  • edited December 2012 Posts: 0Vote Up0Vote Down
    Just a quick comment. make sure that the LCD is either 3.3 Volts compliant or use level shifting an give it 5 Volts.

    I have had some (old) that appeared to work, only sometimes, at 3.3 V.
  • edited December 2012 Posts: 11Vote Up0Vote Down
    well... i'm sure that the lcd needs 5 volts...
    trying with 3.3 doesn't even blink....
  • edited December 2012 Posts: 0Vote Up0Vote Down
    You should be able to power the LCD with 5v and run 3.3v signals to the shift registers without any problems. BTW... you can save a cog and use a simple Spin method to transmit data and control bytes to your LCD.
    Jon McPhalen<div>Burbank, CA</div>
  • edited December 2012 Posts: 11Vote Up0Vote Down
    JonnyMac wrote: »
    You should be able to power the LCD with 5v and run 3.3v signals to the shift registers without any problems.
    it's a soldered chip... the shift register voltage is reduced to 3.3 volt using a transistor....
    BTW... you can save a co and use a simple Spin method to transmit data and control bytes to your LCD.
    it doesn't really matter how much cogs i use, i could link two propeller chips if I use more than 8 cogs ( ok... the link costs one cog... so i will actually have 15 cogs... but 15 cogs are really enough :) ), but a pure spin code would be fantastic
  • edited December 2012 Posts: 0Vote Up0Vote Down
    it doesn't really matter how much cogs i use

    Believe me, for some project it will. Habits are hard to break... especially bad ones. Learn to conserve cogs, even when you don't *need* to; you'll be happy you did.

    I you explained how the 595s are connected to the LCD then one or more of us could write you some code. Accessing a 595 is pretty trivial.
    Jon McPhalen<div>Burbank, CA</div>
  • edited December 2012 Posts: 11Vote Up0Vote Down
    JonnyMac wrote: »
    Believe me, for some project it will. Habits are hard to break... especially bad ones.
    I know, indeed
    Learn to conserve cogs, even when you don't *need* to; you'll be happy you did.
    Well it's a good idea...
    I you explained how the 595s are connected to the LCD then one or more of us could write you some code. Accessing a 595 is pretty trivial.
    i hope it...
Sign In or Register to comment.