+ Reply to Thread
Results 1 to 7 of 7

Thread: 2x16 LCD on propeller

  1. #1

    Default 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 )

    Code:
    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?

  2. #2

    Default Re: 2x16 LCD on propeller

    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.

  3. #3

    Default Re: 2x16 LCD on propeller

    well... i'm sure that the lcd needs 5 volts...
    trying with 3.3 doesn't even blink....

  4. #4

    Default Re: 2x16 LCD on propeller

    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
    Burbank, CA

  5. #5

    Default Re: 2x16 LCD on propeller

    Quote Originally Posted by JonnyMac View Post
    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

  6. #6

    Default Re: 2x16 LCD on propeller

    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
    Burbank, CA

  7. #7

    Default Re: 2x16 LCD on propeller

    Quote Originally Posted by JonnyMac View Post
    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...

+ Reply to Thread

Similar Threads

  1. Cheap 2x16 line LCD screen needed for Propeller
    By Philldapill in forum Propeller 1 Multicore Microcontroller
    Replies: 9
    Last Post: 12-09-2008, 07:50 PM
  2. 2x16 LCD and Propeller
    By shmow in forum Propeller 1 Multicore Microcontroller
    Replies: 5
    Last Post: 07-15-2008, 10:56 AM
  3. 2x16 lcd ?
    By electromanj in forum BASIC Stamp
    Replies: 10
    Last Post: 12-22-2007, 01:50 PM
  4. LCD 2x16
    By hmlittle59 in forum General Discussion
    Replies: 2
    Last Post: 12-04-2007, 12:02 PM
  5. GPS and a 2x16 LCD to a BS2 Anyone?
    By Migs in forum BASIC Stamp
    Replies: 7
    Last Post: 07-21-2007, 11:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts