Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

z8 emulator and seiko m1632 lcd interfacing

Status
Not open for further replies.

whenitz

New Member
please help me to intereface seiko 2x16 lcd to z8 emulator..

lcd m1632 pin config:

pin
1 ---------------> d7
2 ---------------> d6
3 ---------------> d5
4 ---------------> d4
5 ---------------> d3
6 ---------------> d2
7 ---------------> d1
8 ---------------> d0
9 ---------------> enable signal
10 --------------> r/w
11 --------------> rs
12 --------------> Vo
13 --------------> ground
14 --------------> +Vcc

Z8 emulator oin configuration:

Pin No. Name Description
1 GND Logic Ground
2 AD7 MUX Address/Data Bus Bit 7
3 GND Logic Ground
4 AD6 MUX Address/Data Bus Bit 6
5 GND Logic Ground
6 AD5 MUX Address/Data Bus Bit 5
7 GND Logic Ground
8 AD4 MUX Address/Data Bus Bit 4
9 GND Logic Ground
2 AD3 MUX Address/Data Bus Bit 3
11 GND Logic Ground
2 AD2 MUX Address/Data Bus Bit 2
13 GND Logic Ground
2 AD1 MUX Address/Data Bus Bit 1
15 GND Logic Ground
2 AD0 MUX Address/Data Bus Bit 0
17 GND Logic Ground
18 NC No Connection
19 A9 Address Bus Bit 9
20 P27 I/O port Port 2 bit 7
21 A8 Address Bus Bit 8
22 P26 I/O port Port 2 bit 6
23 P36 Output Port3 Bit 6, used as output strobe when expanded
I/O is used
24 P25 I/O port Port 2 bit 5
25 P35 Output Port3 Bit 5, used as input strobe when expanded
I/O is used
26 P24 I/O port Port 2 bit 4
27 P34 Output Port3 Bit 4
28 P23 I/O port Port 2 bit 3
29 P33 Input port Port 3 Bit 3
30 P22 I/O port Port 2 bit 2
31 P32 Input port Port 3 Bit 2
32 P21 I/O port Port 2 bit 1
33 P31 Input port Port 3 Bit 1
34 P20 I/O port Port 2 bit

program:

;P20-P23 = DB4-DB7
;P24 = RS
;P25 = Enable

lower_nib .equ 40h
upper_nib .equ 41h
byte .equ 42h
counter .equ 43h
linecounter .equ 44h

RS .equ 10h
enable .equ 20h
func_set .equ 28h
disp_cont .equ 0ch
entry_mode .equ 06h
clr_display .equ 01h
ret_home .equ 02h
cg_ram .equ 40h
dd_ram1 .equ 80h
dd_ram2 .equ 0c0h
dd_ram3 .equ 94h
dd_ram4 .equ 0d4h
nibble_mask .equ 0fh
byte_mask .equ 0f0h

p31 .equ 02h
p32 .equ 04h
p33 .equ 08h
t0irqmask .equ 10h
t1irqmask .equ 20h
bitmask .equ 40h

.org 00h
.word BEGIN ;P32 Falling
.word BEGIN ;P33 Falling
.word BEGIN ;P31 Falling
.word BEGIN ;P32 Rising
.word BEGIN ;T0
.word BEGIN ;T1
.org 100ch
;---------------------------------------------------------------------------------------
BEGIN:
di ;disable interrupr
; ld p01m,#04h ;port 0 output, internal stack
ld p3m,#01h ;push pull
ld p2m,#00h
ld spl,#80h ;stack pointer at 80h
srp #10h
; ld pre0,#00000101
; ld pre1,#00000111b
; ld imr,#00100000b
clr irq
clr ipr
;----------------------------------------------------------------------------------
clr p2
clr p3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main program ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

call LCD_INIT
; ld byte,#40h
; call send
; call delay
;; or p2,#RS
; ld byte,#00h
; call send
;; ld byte,#0ah
; call send
; ld byte,#15h
; call send
; ld byte,#11h
; call send
; ld byte,#0ah
; call send
; ld byte,#04h
; call send
; ld byte,#00h
; call send
; ld byte,#00h
; call send
; call delay
; and p2,#~RS
; ld byte,#80h
; call send
; call delay
; or p2,#RS
;gh:
; ld byte,#00h
; call send
; jr gh
start:
ld byte,#dd_ram1
call send
call delay
or p2,#RS
ld r8,#>message1
ld r9,#<message1
call write_line
and p2,#~RS
ld byte,#dd_ram2
call send
call delay
or p2,#RS
ld r8,#>message2
ld r9,#<message2
call write_line
and p2,#~RS
ld byte,#dd_ram3
call send
call delay
or p2,#RS
ld r8,#>message3
ld r9,#<message3
call write_line
and p2,#~RS
ld byte,#dd_ram4
call send
call delay
or p2,#RS
ld r8,#>message4
ld r9,#<message4
call write_line
call delay
call delay
call delay
; jp start
and p2,#~RS
; ld byte,#dd_ram1
; call send
ld counter,#40
try:
ld byte,#18h
call send
call delay
call delay
call delay
dec counter
jr nz,try
call delay_500mS
call delay_500mS
ld byte,#clr_display
call send
; ld byte,#ret_home
; call send
call delay
call delay
call delay

jp 1023h

message1:
.ascii " e-Gizmo "
message2:
.ascii " Mechatronix "
message3:
.ascii " The Spirit "
message4:
.ascii " of invention "

write_line:
ld counter,#20
read:
ldc r3,@rr8
ld byte,r3
call send
incw rr8
call delay
dec counter
jr nz,read
ret

LCD_INIT:
and p2,#~RS
ld byte,#00h
call send
ld byte,#func_set
call send
call send
call send
ld byte,#disp_cont
call send
ld byte,#entry_mode
call send
ld byte,#clr_display
call send
ld byte,#ret_home
call send
ld byte,#cg_ram
call send
ld byte,#dd_ram1
call send
call delay
ret

;Send_Ins:
; tm p2,#RS
; jr nz,ins
; call wait
; or p2,#RS
;ins:
; call split_byte
; or p2,#~byte_mask
; and p2,~upper_nib
; and p2,#~enable
; or p2,#enable
; or p2,#~byte_mask
; and p2,~lower_nib
; and p2,#~enable
; or p2,#enable
; or p2,#~byte_mask
; ld r1,#1fh
;dely:
; djnz r1,dely
; ret

send:
call split_byte
and p2,#byte_mask
or p2,upper_nib
or p2,#enable
; nop
; nop
; nop
and p2,#~enable
; call wait_1
and p2,#byte_mask
or p2,lower_nib
or p2,#enable
; nop
; nop
; nop
and p2,#~enable
and p2,#byte_mask
call delay
ret

split_byte:
ld lower_nib,byte
and lower_nib,#nibble_mask
ld upper_nib,byte
swap upper_nib
and upper_nib,#nibble_mask
ret

TEST_SWITCH:
tm p3,#04h ;P32
jr nz,end_test_switch
call delay
tm p3,#04h ;P32
jr nz,end_test_switch

back:
tm p3,#04h ;P32
jr z,back
; nop
; stop
end_test_switch:
ret


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; delay subroutine ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

wait_1:
ld r4,#1fh
busy:
djnz r4,busy
ret

delay:
ld r0,#03fh ; initialize count down timer (try changing the value)
lop:
ld r1,#0ffh ; initialize count down timer (try changing the value)
lop2:
djnz r1,lop2 ; decrement and loop back until r1 is zero
djnz r0,lop ; decrement and loop back until r0 is zero
ret

delay_592uS: ; using 7.2 Mh crystal
nop
nop
nop
ld r0,#69 ;6 cycles
loop2:
nop ;6 cycles
nop ;6 cycles
dec r0 ;6 cycles
jr nz,loop2 ;12 cycles
ret

delay_250mS: ; using 15.5433 Mhz crystal
ld r0,#03h ; initialize count down timer (try changing the value)
loop3:
ld r1,#0d1h ; initialize count down timer (try changing the value)
loop4:
ld r2,#0ffh ; initialize count down timer (try changing the value)
loop5:
djnz r2,loop5 ; decrement and loop back until r2 is zero
djnz r1,loop4 ; decrement and loop back until r1 is zero
djnz r0,loop3 ; decrement and loop back until r0 is zero
ret

delay_500mS: ; using 15.5433 Mhz crystal
ld r0,#06h ; initialize count down timer (try changing the value)
loop6:
ld r1,#0d1h ; initialize count down timer (try changing the value)
loop7:
ld r2,#0ffh ; initialize count down timer (try changing the value)
loop8:
djnz r2,loop5 ; decrement and loop back until r2 is zero
djnz r1,loop4 ; decrement and loop back until r1 is zero
djnz r0,loop3 ; decrement and loop back until r0 is zero
ret

.END


i need a schematic to make this progaram work and dispaly it to the lcd..i see a simillar circuit but i dont know what particular pins to be use to make a display..tnx!
 
whenitz said:
please help me to intereface seiko 2x16 lcd to z8 emulator..

lcd m1632 pin config:

pin
1 ---------------> d7
2 ---------------> d6
3 ---------------> d5
4 ---------------> d4
5 ---------------> d3
6 ---------------> d2
7 ---------------> d1
8 ---------------> d0
9 ---------------> enable signal
10 --------------> r/w
11 --------------> rs
12 --------------> Vo
13 --------------> ground
14 --------------> +Vcc

Z8 emulator oin configuration:

Pin No. Name Description
1 GND Logic Ground
2 AD7 MUX Address/Data Bus Bit 7
3 GND Logic Ground
4 AD6 MUX Address/Data Bus Bit 6
5 GND Logic Ground
6 AD5 MUX Address/Data Bus Bit 5
7 GND Logic Ground
8 AD4 MUX Address/Data Bus Bit 4
9 GND Logic Ground
2 AD3 MUX Address/Data Bus Bit 3
11 GND Logic Ground
2 AD2 MUX Address/Data Bus Bit 2
13 GND Logic Ground
2 AD1 MUX Address/Data Bus Bit 1
15 GND Logic Ground
2 AD0 MUX Address/Data Bus Bit 0
17 GND Logic Ground
18 NC No Connection
19 A9 Address Bus Bit 9
20 P27 I/O port Port 2 bit 7
21 A8 Address Bus Bit 8
22 P26 I/O port Port 2 bit 6
23 P36 Output Port3 Bit 6, used as output strobe when expanded
I/O is used
24 P25 I/O port Port 2 bit 5
25 P35 Output Port3 Bit 5, used as input strobe when expanded
I/O is used
26 P24 I/O port Port 2 bit 4
27 P34 Output Port3 Bit 4
28 P23 I/O port Port 2 bit 3
29 P33 Input port Port 3 Bit 3
30 P22 I/O port Port 2 bit 2
31 P32 Input port Port 3 Bit 2
32 P21 I/O port Port 2 bit 1
33 P31 Input port Port 3 Bit 1
34 P20 I/O port Port 2 bit

program:

;P20-P23 = DB4-DB7
;P24 = RS
;P25 = Enable

lower_nib .equ 40h
upper_nib .equ 41h
byte .equ 42h
counter .equ 43h
linecounter .equ 44h

RS .equ 10h
enable .equ 20h
func_set .equ 28h
disp_cont .equ 0ch
entry_mode .equ 06h
clr_display .equ 01h
ret_home .equ 02h
cg_ram .equ 40h
dd_ram1 .equ 80h
dd_ram2 .equ 0c0h
dd_ram3 .equ 94h
dd_ram4 .equ 0d4h
nibble_mask .equ 0fh
byte_mask .equ 0f0h

p31 .equ 02h
p32 .equ 04h
p33 .equ 08h
t0irqmask .equ 10h
t1irqmask .equ 20h
bitmask .equ 40h

.org 00h
.word BEGIN ;P32 Falling
.word BEGIN ;P33 Falling
.word BEGIN ;P31 Falling
.word BEGIN ;P32 Rising
.word BEGIN ;T0
.word BEGIN ;T1
.org 100ch
;---------------------------------------------------------------------------------------
BEGIN:
di ;disable interrupr
; ld p01m,#04h ;port 0 output, internal stack
ld p3m,#01h ;push pull
ld p2m,#00h
ld spl,#80h ;stack pointer at 80h
srp #10h
; ld pre0,#00000101
; ld pre1,#00000111b
; ld imr,#00100000b
clr irq
clr ipr
;----------------------------------------------------------------------------------
clr p2
clr p3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main program ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

call LCD_INIT
; ld byte,#40h
; call send
; call delay
;; or p2,#RS
; ld byte,#00h
; call send
;; ld byte,#0ah
; call send
; ld byte,#15h
; call send
; ld byte,#11h
; call send
; ld byte,#0ah
; call send
; ld byte,#04h
; call send
; ld byte,#00h
; call send
; ld byte,#00h
; call send
; call delay
; and p2,#~RS
; ld byte,#80h
; call send
; call delay
; or p2,#RS
;gh:
; ld byte,#00h
; call send
; jr gh
start:
ld byte,#dd_ram1
call send
call delay
or p2,#RS
ld r8,#>message1
ld r9,#<message1
call write_line
and p2,#~RS
ld byte,#dd_ram2
call send
call delay
or p2,#RS
ld r8,#>message2
ld r9,#<message2
call write_line
and p2,#~RS
ld byte,#dd_ram3
call send
call delay
or p2,#RS
ld r8,#>message3
ld r9,#<message3
call write_line
and p2,#~RS
ld byte,#dd_ram4
call send
call delay
or p2,#RS
ld r8,#>message4
ld r9,#<message4
call write_line
call delay
call delay
call delay
; jp start
and p2,#~RS
; ld byte,#dd_ram1
; call send
ld counter,#40
try:
ld byte,#18h
call send
call delay
call delay
call delay
dec counter
jr nz,try
call delay_500mS
call delay_500mS
ld byte,#clr_display
call send
; ld byte,#ret_home
; call send
call delay
call delay
call delay

jp 1023h

message1:
.ascii " e-Gizmo "
message2:
.ascii " Mechatronix "
message3:
.ascii " The Spirit "
message4:
.ascii " of invention "

write_line:
ld counter,#20
read:
ldc r3,@rr8
ld byte,r3
call send
incw rr8
call delay
dec counter
jr nz,read
ret

LCD_INIT:
and p2,#~RS
ld byte,#00h
call send
ld byte,#func_set
call send
call send
call send
ld byte,#disp_cont
call send
ld byte,#entry_mode
call send
ld byte,#clr_display
call send
ld byte,#ret_home
call send
ld byte,#cg_ram
call send
ld byte,#dd_ram1
call send
call delay
ret

;Send_Ins:
; tm p2,#RS
; jr nz,ins
; call wait
; or p2,#RS
;ins:
; call split_byte
; or p2,#~byte_mask
; and p2,~upper_nib
; and p2,#~enable
; or p2,#enable
; or p2,#~byte_mask
; and p2,~lower_nib
; and p2,#~enable
; or p2,#enable
; or p2,#~byte_mask
; ld r1,#1fh
;dely:
; djnz r1,dely
; ret

send:
call split_byte
and p2,#byte_mask
or p2,upper_nib
or p2,#enable
; nop
; nop
; nop
and p2,#~enable
; call wait_1
and p2,#byte_mask
or p2,lower_nib
or p2,#enable
; nop
; nop
; nop
and p2,#~enable
and p2,#byte_mask
call delay
ret

split_byte:
ld lower_nib,byte
and lower_nib,#nibble_mask
ld upper_nib,byte
swap upper_nib
and upper_nib,#nibble_mask
ret

TEST_SWITCH:
tm p3,#04h ;P32
jr nz,end_test_switch
call delay
tm p3,#04h ;P32
jr nz,end_test_switch

back:
tm p3,#04h ;P32
jr z,back
; nop
; stop
end_test_switch:
ret


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; delay subroutine ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

wait_1:
ld r4,#1fh
busy:
djnz r4,busy
ret

delay:
ld r0,#03fh ; initialize count down timer (try changing the value)
lop:
ld r1,#0ffh ; initialize count down timer (try changing the value)
lop2:
djnz r1,lop2 ; decrement and loop back until r1 is zero
djnz r0,lop ; decrement and loop back until r0 is zero
ret

delay_592uS: ; using 7.2 Mh crystal
nop
nop
nop
ld r0,#69 ;6 cycles
loop2:
nop ;6 cycles
nop ;6 cycles
dec r0 ;6 cycles
jr nz,loop2 ;12 cycles
ret

delay_250mS: ; using 15.5433 Mhz crystal
ld r0,#03h ; initialize count down timer (try changing the value)
loop3:
ld r1,#0d1h ; initialize count down timer (try changing the value)
loop4:
ld r2,#0ffh ; initialize count down timer (try changing the value)
loop5:
djnz r2,loop5 ; decrement and loop back until r2 is zero
djnz r1,loop4 ; decrement and loop back until r1 is zero
djnz r0,loop3 ; decrement and loop back until r0 is zero
ret

delay_500mS: ; using 15.5433 Mhz crystal
ld r0,#06h ; initialize count down timer (try changing the value)
loop6:
ld r1,#0d1h ; initialize count down timer (try changing the value)
loop7:
ld r2,#0ffh ; initialize count down timer (try changing the value)
loop8:
djnz r2,loop5 ; decrement and loop back until r2 is zero
djnz r1,loop4 ; decrement and loop back until r1 is zero
djnz r0,loop3 ; decrement and loop back until r0 is zero
ret

.END


i need a schematic to make this progaram work and dispaly it to the lcd..i see a simillar circuit but i dont know what particular pins to be use to make a display..tnx!
i have the same LCD with you, i bought it in ebay. m1632 with green backlight. but im not familiar with z8.

i make it work and display. I used PIC16f84 and the LCD in 4bit mode (pin conservation :D ) and all of the pins I used are digital I/O ports (all of them in PORTB - one pin unused). i just tie the Vo to ground since i dont have potentiometer when i tried to interface it with PIC :D
 
thanks..

i already tried to connect all the pin to p2..i think its portb in pic,may i know what pin you actually use for the write,enable and rs..as you can see in the program db4-db7 = p20-p23 rs = p24 and enable = p25..i dont know what pin should i use for the write..power supply of the lcd in no prob..BTW,thanks a lot..
 
i have tried interfacing z8 with a LCD and it works well (scrolling message display), check your LCD datasheet for timing requirements.
 
lcd interfacing

can you please give the schematic diagram that you use..i need this ti omy thesis project..thanks!
 
i've seen 14 and 16 pin versions. the only difference seam to be two extra pins for background illumination.
timing is not always the same (newer units tipically show much less fuss than original HD448xx).
just Google for "HD44780 compatible LCD"
 
Last edited:
are you sure about that pin out? most 44780s have the pin numbers going the other way (1 is Vcc, 14 is data 7).
 
lcd interfacing

i dont have the schematic diagram..what i did is connect each pins and port that the porgram uses..

the program is running in 4bit mode, so db0 to db4 was not used..

db4 to db7 is connected to p20 to p23(pin 34,32,30,28 in z8mulator) check the pin pin config.

rs is connected to p24(pin 26 in z8mulator).

enable is connected to p25(pin 24 in z8mulator).

vcc connected at the one end of the potentiometer ground at the other end and Vo at the middle for contrast..

i dont get any output, im just powering up the lcd no characters..
 
LcD interfacing

you seem to be from the phils too, why don't you bring to me your project or see mine how it works, sa Q.C. ako
 
you don't mention the R/W pin. you should connect this to either ground (for writing only) or to a pin for read and write.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top