Keypad is fine LCD still trouble. I have more details.

Started by cubddh2003 March 20, 2004
For my LCD, I tie the contrast brightness pin 3 to ground. Im pretty
sure this is fine. I know all my signals are connected properly.
When i write a character to the screen, I get a dark block. IF i
write 2 characters i get 2 dark blocks. ect. It is 2x16 and i
always have 1 line of the 16 with all dark blocks. When i put it in
1 line mode then i can write to it but i still have one line with
those black boxes. I guess it is partly burnt but i really dont
think so. So in conclusion when i write to it, it gives me black
boxes solid. And the address increments by one.
Please help and thanks for your responses.
mark prior.



Your contrast is probably too high when tied to ground.
It's supposed to be a variable voltage slightly above ground.
I use 2 diodes in series which seems sufficient.

If you look at the LCD from different angles you may
actually see your nearly saturated characters.

cubddh2003 wrote:
>
> For my LCD, I tie the contrast brightness pin 3 to ground. Im pretty
> sure this is fine. I know all my signals are connected properly.
> When i write a character to the screen, I get a dark block. IF i
> write 2 characters i get 2 dark blocks. ect. It is 2x16 and i
> always have 1 line of the 16 with all dark blocks. When i put it in
> 1 line mode then i can write to it but i still have one line with
> those black boxes. I guess it is partly burnt but i really dont
> think so. So in conclusion when i write to it, it gives me black
> boxes solid. And the address increments by one.
> Please help and thanks for your responses.
> mark prior.



I wonder if the data is getting bollixed up somehow. Do you have a
digital/storage scope so that you can freeze the wave form and verify the
timing?

Short of that, you might try writing every 8 bit combination to the
display, at a slow enough interval so that you can read each one as it goes
by. The problem is that I don't think it is bit patterns, but bit timing.

Gary Olmstead
Toucan Technology
Ventura CA At 03:00 PM 3/20/04, you wrote:
>For my LCD, I tie the contrast brightness pin 3 to ground. Im pretty
>sure this is fine. I know all my signals are connected properly.
>When i write a character to the screen, I get a dark block. IF i
>write 2 characters i get 2 dark blocks. ect. It is 2x16 and i
>always have 1 line of the 16 with all dark blocks. When i put it in
>1 line mode then i can write to it but i still have one line with
>those black boxes. I guess it is partly burnt but i really dont
>think so. So in conclusion when i write to it, it gives me black
>boxes solid. And the address increments by one.
>Please help and thanks for your responses.
>mark prior. >--------------------To learn more
>about Motorola Microcontrollers, please visit
>http://www.motorola.com/mcu
>o learn more about Motorola Microcontrollers, please visit
>http://www.motorola.com/mcu
>
>Yahoo! Groups Links >
>





Take 10K potentiometer to control the contrast. Tie pin 1 to Vcc,
pin 2 to LCD contrast pin and 3 to ground.

Adjust until you could hardly see the pixels.

You probably used these init code already.. If you don't here they
are. Keypad code below too.

lcd_ctrl equ %00010000 ;Port S bit 4 = 0 -
Instruction in
lcd_data equ %00010000 ;Port S bit 4 = 1 -
Data in
lcd_enable equ %10000000 ;Port S bit 7 - enable
BL EQU $20

us22 equ 175
us11 equ 88
us1 equ 8
ms100 equ $61a8
ms1 equ $9c3
TEN equ $80 ; Memory Allocation
;disp_buffer ds 32 ;display buffer (2 lines of
16 chars)
;disp_ptr ds 2 ;pointer to display buffer
;disp_flag ds 1 ;1 = update; 0 = home; -1 =
done
;drow_var ds 1
;temp ds 1
;lcd_state ds 2

;---------------------------------
--------
; Display Initialization
; ----------------------

disp_init

;Initialize PORTS
bclr PORTS,%10010000
bset DDRS,%10010000 ;Set direction for lcd
control and enabe
clr drow_var
clr disp_flag

;Initialize PORTJ
movb #$ff,DDRJ ;Bit 7->0 of PORTJ are Output
movb #$00,PORTJ

bclr PORTS,lcd_enable
bclr PORTS,lcd_ctrl ;Set Port S bit 4 to zero

movb TMSK2,temp
bset TSCR,$B0 ;enable the timer sysem. set for fast
flag clears
bset TIOS,%01 ;enable timer channel 0 as an output
compare.
movb #$5,TMSK2 ;set the prescaler to /32

ldd #ms1*$0f ;15 millisecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb #%00110000,PORTJ ;8 data bits, 2 display
lines, 0
jsr toggle_lcd_ctrl

; bset PORTS,lcd_enable
; ldy #10000
;lp1
; dbne y,lp1
; bclr PORTS,lcd_enable

movb #$00,TMSK2 ;set the prescaler to /1
ldd #us1*4 ;40 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb #%00111000,PORTJ ;8 data bits, 2 display
lines, 0
jsr toggle_lcd_ctrl

ldd #us1*4 ;40 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb #%1100,PORTJ ;display on, cursor off,
blink off
jsr toggle_lcd_ctrl

ldd #us1*100 ;100 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb #%1,PORTJ ;Clear display and return
cursor to home
jsr toggle_lcd_ctrl

ldd #us1*4 ;40 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb #%01000000,PORTJ
jsr toggle_lcd_ctrl

ldd #us1*4 ;40 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

ldx #cgram_table
ldab #CGRAM_LEN
jsr line_update

movb #%10000000,PORTJ
jsr toggle_lcd_ctrl

ldd #us1*4 ;40 microsecond delay
addd TCNT
std TC0
brclr TFLG1,$01,*

movb temp,TMSK2 ;set the prescaler to
original parameters

ldx #disp_menu1
stx lcd_state

movb #0,drow_var
jsr drow
ldx #Testing1
jsr dstr

movb #1,drow_var
jsr drow
ldx #Testing2
jsr dstr

ldx #_1SECOND*3
stx lcd_timer

movb #0,drow_var
jsr drow
ldx #Testing1
jsr dstr

movb #1,drow_var
jsr drow
ldx #Testing2
jsr dstr

rts

toggle_lcd_ctrl
bclr PORTS,lcd_ctrl
nop
nop
nop
nop
nop
nop

bset PORTS,lcd_enable

nop
nop
nop
nop
nop
nop

bclr PORTS,lcd_enable
nop
nop
nop
rts toggle_lcd_data
bset PORTS,lcd_data
nop
nop
nop
nop
nop
nop

bset PORTS,lcd_enable

nop
nop
nop
nop
nop
nop

bclr PORTS,lcd_enable
nop
nop
nop

Keypad code??? You probably have these too
*---------------------------------
--------
keypad_press
ldaa keypad_flag
beq check_p10
ldaa keypad_var

*do what you need to do here

jsr SB1 ;Data is in Reg A, display
keypress to sci
clr keypad_flag ;Keypad interrupt is enabled
in Real Time Int.

check_p10
rts

keypad_init
ldy #REG
ldaa #$f0
staa DDRC,y ;Initialize portc
staa PORTC,y ;Disable keypad int. until
ready
clr keypad_flag

ldaa #3 ;Enable keypad int when this
timer is clear
staa keypad_timer

rts

keypad_int
ldy #REG
jsr key_init_int

next_keypad10
dec keypad_counter
beq next_key10

jsr check_next_pad
brset PORTC,y,%0001,next_keypad10 ;Check next pad

ldx #keypad_table0 ;Get keypad value
jsr get_keypad_val ;Reg b has keypad value
stab keypad_var

ldaa #1
staa keypad_flag ;set flag for valid keypress
ldaa #$FF ;Disable keypad until present
press is service
staa PORTC,y

ldaa #30 ;
staa keypad_timer ;Delay before next keypad
interrupt

bra kp_exit10

next_key10
jsr key_init_int

next_keypad20
dec keypad_counter
beq next_key20

jsr check_next_pad
brset PORTC,y,%0010,next_keypad20 ;Check next pad

ldx #keypad_table1 ;Get keypad value
jsr get_keypad_val ;Reg b has keypad value
stab keypad_var

ldaa #1
staa keypad_flag ;set flag for valid keypress
ldaa #$FF ;Disable keypad until present
press is service
staa PORTC,y

ldaa #30 ;
staa keypad_timer ;Delay before next keypad
interrupt

bra kp_exit10

next_key20
jsr key_init_int

next_keypad30
dec keypad_counter
beq next_key30

jsr check_next_pad
brset PORTC,y,%0100,next_keypad30 ;Check next pad

ldx #keypad_table2 ;Get keypad value
jsr get_keypad_val ;Reg b has keypad value
stab keypad_var

ldaa #1
staa keypad_flag ;set flag for valid keypress
ldaa #$FF ;Disable keypad until present
press is service

ldy #REG
staa PORTC,y

ldaa #30 ;
staa keypad_timer ;Delay before next keypad
interrupt

bra kp_exit10

next_key30
jsr key_init_int

next_keypad40
dec keypad_counter
beq kp_exit

jsr check_next_pad
brset PORTC,y,%1000,next_keypad40 ;Check next pad

ldx #keypad_table3 ;Get keypad value
jsr get_keypad_val ;Reg b has keypad value
stab keypad_var

ldaa #1
staa keypad_flag ;set flag for valid keypress
ldaa #$FF ;Disable keypad until present
press is service
staa PORTC,y

ldaa #30 ;Delay before next keypad
interrupt
staa keypad_timer

bra kp_exit10

kp_exit
clr keypad_flag

kp_exit10
rti

key_init_int
ldab #%11110111
stab keypad_temp
ldaa #5
staa keypad_counter
rts

check_next_pad
ldy #REG
ldab keypad_temp
lslb
stab PORTC,y
stab keypad_temp
rts

get_keypad_val
ldab keypad_temp
lsrb
lsrb
lsrb
lsrb
comb
andb #$0f ;clear high nibbles

abx
ldab 0,x
rts

keypad_table0
fcc '?'
fcc '1' ;ok
fcc '2'
fcc '?'
fcc '3'
fcc '?'
fcc '?'
fcc '?'

keypad_table1
fcc 'A' ;ok
fcc '4' ;ok
fcc '5'
fcc '?'
fcc '6'
fcc '?'
fcc '?'
fcc '?'

keypad_table2
fcc 'B' ;ok
fcc '7' ;ok
fcc '8'
fcc '*'
fcc '9'
fcc '?'
fcc '?'
fcc '?'

keypad_table3
fcc 'C' ;ok
fcc '*' ;ok
fcc '0'
fcc '?'
fcc '#'
fcc '?'
fcc '?'
fcc '?'
fcc 'D'