2x16 LCD on propeller
BlackPHP
Posts: 11
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 )
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?
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?
Comments
I have had some (old) that appeared to work, only sometimes, at 3.3 V.
trying with 3.3 doesn't even blink....
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.
i hope it...