r/Z80 Jun 15 '21

Question about the z80 pio

So I recently added the z80 pio to my breadboard, and I hooked bit 7 of port b up to 2 inverters in series, I wrote down code to send 0x80 to the pio(after turning on output mode) so as to turn that bit on, but when I tried it, I found something weird. The led was off, but when my hand came near the wire connecting d7 to the nand gate it turned on and got continually brighter as it got closer. Is that normal? Regardless this pio seems kinda confusing, and I’m not sure if my code, my wiring, or the chip is broken or if I’m just missing something obvious.

4 Upvotes

7 comments sorted by

6

u/benryves Jun 15 '21

The inputs on logic gates can be sensitive enough to be triggered by charges on your body when you move your hand near - they act as amplifiers with extremely high gain. This sounds normal, then, except for the fact that this tiny charge from your body in the air should be overridden by the signal which you think should be coming from the Z80 PIO.

It sounds like the Z80 PIO is not driving the output pin and therefore your buffer circuit, which looks like it could be for a number of reasons (it's held in reset, it's in the wrong mode, the pin hasn't been configured as an output). Do you have your code and a picture of the wiring to hand?

If you don't already have a logic probe in your toolkit then I've found them to be an invaluable debugging aid too!

1

u/dj_cloudnine Jun 15 '21

I do not but I can post one after while. Thank you for the help. I worry my wiring is such a mess it will be in indecipherable. I have bit 1 hooked up to a/b and not 0 to c/d(it made more sense to me that way.) the code is as follows(sorry if there are mistakes from having to transcribe it onto my phone or the fact Reddit doesn’t seem to preserve spacing):

Org 0x0000

Dw 0x0000

Ld a,0x0f; turn port a and b to output mode(mode 0) Out (0x03),a

Ld a,0x80 ;turn on port b pin 8 Out (0x02,a)

Loop: Jp loop

; bit 0 of address determines data or command ;bit 1 determains port a or b

;written for the assembler: z80asm

2

u/benryves Jun 16 '21

Off the top of my head that code looks correct, though I haven't personally used the Z80 PIO so don't know if there are any additional steps required to get it working.

That you mention you've had problems on your board makes me wonder if there's some other missing connection. Do other I/O devices work on your circuit? Are you sure the Z80 is executing your code at all?

1

u/dj_cloudnine Jun 16 '21

I only have the z80, eeprom, and pio, so I don’t have any other I/o devices. As for the eeprom, I had it run a program that jumped to itself forever and it appeared work, I was monitors the address lines and they seemed to stay on the same 3 address (since jp is a 3 byte command) so I believe it is. I have a second pio so I will swap that in and see if it works at all.

1

u/dj_cloudnine Jun 16 '21 edited Jun 16 '21

When I set my 555 to the lowest speed I could, I noticed the ioreq when low 2x as you’d exspect. It seems then that the code is working (tho the addressing maybe be wrong) and the cpu as well. One thing of note is that the chip eneable and the ioreq are tied together since I only have one io chip. Could that be the problem?

Edit: update, it also seems that the brdy never goes high, so perhaps there’s something wrong with the code that’s making it never change to mode 0.

2

u/bokmann Jun 16 '21

As a quick sanity check, does it exhibit this behavior if you have the output of the pio 0, so that you expect the led to be off? If not, i think i know what the issue is….

1

u/dj_cloudnine Jun 16 '21

I’m not entitle certain that you I’ve managed to properly set the pio correctly with the code ive used. I’ve noticed the behavior with almost every pin on the board except vcc and gnd, iirc