Connecting a 1980s Z80 CPU to an Arduino, making a hardware debugger.

Sdílet
Vložit
  • čas přidán 11. 07. 2024
  • I'm a programmer, the CPU is a mystic black box that gets fed instructions. I'm trying to learn and work out what the CPU really does. Here I build a system to control and watch the Z80's functions.
    This was inspired by Ben Eater's 6502 and 8Bit CPU videos, and is what I based my Arduino code on.

Komentáře • 43

  • @jimtekkit
    @jimtekkit Před rokem +6

    This video was helpful for me when cross-checking with my own results. As it turns out, BOTH the Z80 chips I have are defective and the outputs are static regardless of what I do. It's always worth spending a little extra and ordering through a reputable distributor like Mouser to get a brand new working chip. When starting out it's difficult to recognize whether you've screwed up or a part is defective.

  • @arronshutt
    @arronshutt Před 4 lety +4

    Very nice. Expert editing with windowed scope displays and code displays. I like how all the hardware diagrams are using NCOT branding :)

  • @mharding1258
    @mharding1258 Před 3 lety +5

    Can I recommend Ben Eater's series on building an 8 bit computer on breadboards. He has excellent understanding and grasp of the concepts you are trying to get your head around. I found his series most helpful.

    • @ballsrgrossnugly
      @ballsrgrossnugly Před rokem

      That was my holy grail while building my own 8 bit CPU on breadboards, and bugger me, it works!
      I also bought a Z80 chip a while back, I really should use it for something one of these days.

  • @leehill8472
    @leehill8472 Před 4 lety +7

    Great video. Also inspired by Ben Eater's videos I bought the same kit.

  • @cristiansky
    @cristiansky Před 2 lety

    Excelente video , me inspira a realizar el montaje arduino Z80 , gracias por compartir !!!

  • @SpeccyMan
    @SpeccyMan Před rokem +2

    FYI the Z80 is a 70's CPU. Also you could've just configured the 555 as a monostable to provide a single pulse per button press. Better still you could've used an output pin on the Arduino to provide the clock for the Z80.

  • @SusanAmberBruce
    @SusanAmberBruce Před 3 lety

    I like the ♬ smiles

  • @joeysartain6056
    @joeysartain6056 Před rokem

    Very interesting. Did you make any othe videos on this?

  • @alnoorratansi9364
    @alnoorratansi9364 Před 3 lety

    Great Tutorial , can you share your single step circuit and code please

  • @Lucretia9000
    @Lucretia9000 Před 3 lety +2

    Is there a second part to this yet?

  • @ballsrgrossnugly
    @ballsrgrossnugly Před rokem +1

    I think I would have connected the arduino direct to the clock and then let it take care of the pulses while testing at least. You can generate a clock on (if I recall) many different pins on an arduino with a little programming.
    EDIT not sure you had a spare pin after watching the whole thing, come to think of it. But as for the eeprom idea, all you have to do is a bit of code to set the bus as output, and you can send an address with data, then receive the result, and so on if you wanted to.

  • @davidtwist3659
    @davidtwist3659 Před 7 měsíci

    Did you ever update this to use RD, WR and MREQ?
    I'm looking to use the arduino to check out a Z80 system to see what is happening.

  • @olavl8827
    @olavl8827 Před 3 lety +1

    Very interesting. Personally I'm more a computer/software person than an electronics person. So perhaps a stupid question, but how do you make the button to give only one short pulse? That seems useful for lots of projects.

    • @ncot_tech
      @ncot_tech  Před 3 lety

      That is a really good question. You can do it in software by effectively sampling the button over a few milliseconds, or you can make a small circuit using a few different techniques.
      What I did was search for things like “Arduino button debounce”.

    • @olavl8827
      @olavl8827 Před 3 lety

      @@ncot_tech Thanks for your reply. I know of the software debounce technique with Arduino but I find it unsatisfactory. Debouncing is a hardware problem that (imho) should be addressed in hardware. I know of RC filters, and personally with Arduino projects I sometimes use optocouplers since I found they also work. Doesn't answer the question though of how to generate only a single pulse of fixed duration after each (long or short) button press.

    • @DavidW27
      @DavidW27 Před 3 lety

      @@olavl8827 Ben Eater does a very detailed description of a simple circuit using a 555 chip in monostable mode, which does what I think you are asking for.
      czcams.com/video/81BgFhm2vz8/video.html

    • @melkiorwiseman5234
      @melkiorwiseman5234 Před rokem

      @@olavl8827 I think the answer to your question is part of Ben Eater's breadboard computer series here on YT. It's fairly early, and he too uses a 555 timer.

    • @airthrowDBT
      @airthrowDBT Před 6 měsíci

      @@olavl8827 I know your comment is really old but for anyone else interested in this, you want to look for a 555 circuit called "monostable", it is a one shot where the duration can be adjusted with simple resistor values (you can use a pot to fine tune), there are calculators online for the values. You can also drive a series of pulses of a specific number by having one 555 in monostable mode drive another 555 in A-stable mode with pre-set duty cycles. (If you have a 556 which is 2x 555s in one you can save space)-The reason I did this is because for a project I wanted a button automatically pressed approximately 29 times.

  • @remim9417
    @remim9417 Před 3 lety

    Bonjour, Très intéressant , mais je pense que ton interruption doit être sur le signal BAS (O volt) sur le MREQ donc FALLING et non RISING.
    Superbe explication , encore Merci :-)

  • @nonchip
    @nonchip Před 3 lety +2

    3:20 "which is not really what the cpu wants to see" actually it doesn't usually care at all, i've clocked a 6MHz Z80 with a 1-statechange-per-minute clock just for the lulz and it worked just fine :P

  • @Tenraiden
    @Tenraiden Před rokem +1

    What’s the music @5:15??

  • @stinchjack
    @stinchjack Před 3 lety +1

    I'm using an Arduino Nano instead of an EEPROM for my Z80 project. Problem I had had is, the Arduino is not a tri-state device. The digital pins behave OK input mode, but the analog pins still draw too much current in input mode and therefore kept pulling my data bus down. I found a 74LS245 bus transceiver didnt work satisfactory, but 74ls241 buffer does enable me to bridge the Arduino Nano to the data bus.
    Bonus for using the Arduino Nano is, My "ROM" emulator code can also disassemble on the fly, which has been amazing for debugging (helped by M1 signal)
    This is limited to 512 bytes of address space for Z80 code on the Arduino, but my Z80 assembly coding is pretty awful and I havent written a program that big yet lol

    • @CristianVeliscu
      @CristianVeliscu Před 3 lety

      What was the problem you encountered with the 74LS245 bus transceiver?

    • @TomTom-rd3iy
      @TomTom-rd3iy Před 3 lety +2

      of course the nano has tri-state io pins - just configure a pin as input

  • @johnwilson3918
    @johnwilson3918 Před 3 lety +1

    Nice going, James! Have you watched Julian Ilett's CZcams channel on the Z80? Your videos are inspiring me to build a Z80 machine. I'm just trying to recall what the bootup sequence of the Z80 is? i.e does it fetch an address from a particular location and jump to there?

    • @johnwilson3918
      @johnwilson3918 Před 3 lety +1

      I'm now looking through the Z80 chip doc - to see if I can answer my own question.

    • @johnwilson3918
      @johnwilson3918 Před 3 lety +2

      Perhaps I'm getting confused with the 6502 - (I should have paid more attention to you single-stepping the Z80) - I can see the address bus starting at 0x0000. I'm slightly confused by the opcode/address debug output. It seems you were initially presented with the instruction 'load hl,0000', and then your upper 8 bits of your address bus suddenly flips.

    • @ncot_tech
      @ncot_tech  Před 3 lety +2

      Yes, I watch Julian's channel (and his side channel where he's building a shed in the exact way an engineer would build one 😁).
      The Z80 looks for code at address zero. I wouldn't look too closely at the output from my Arduino debugger thing, I'm not sure it was working properly. All it was doing was spitting out whatever went across the busses so some of the data was probably coming from other chips and possibly not during the fetch cycle of the CPU.

    • @MRCAGR1
      @MRCAGR1 Před 3 lety +2

      @@johnwilson3918 IIRC the Z80 reset vector is location 0x0, this is usually a jump instruction. There are several RST (reset) instructions which are located in the lowest part of the memory.

    • @CodeAsm
      @CodeAsm Před 3 lety +1

      Also dont forget your stepping the clock, an instruction can take some cycles to read, then the data maybe (unless a instruction is just a jump or halt) and the data could be anything and the z80 would ignore whats happening. Funny to see the databus being equal for like 3 clk pulses, probably has to do with these cycles.

  • @JoaoPaulo-fw3zg
    @JoaoPaulo-fw3zg Před rokem

    I have a simple question. From where the Z80 fetches the instructions? From what I see, there is no memory and the DATA pins are inputs in the Arduino.

    • @ncot_tech
      @ncot_tech  Před rokem

      There are no instructions, I think I’d wired the CPU up to execute nop instructions using a bunch of resistors.

  • @Tenraiden
    @Tenraiden Před rokem +1

    Found the music that's @5:15! Jincheng Zhang - Consider Together 🤍🎶
    czcams.com/video/rJ3hX1qx6L8/video.html

  • @vanhetgoor
    @vanhetgoor Před 2 lety

    Now I am confused, I have always thought that the Arduino was on something like 3,6 Volts logic and I know the Z80 that this pinnacle of technology is working on a powerful 5 Volts. What is happening here?

    • @ncot_tech
      @ncot_tech  Před 2 lety +1

      No the Arduino is 5v too. I think the Pi and a few others are 3.3v the ESP 8266 definitely is.

  • @Thebasicmaker
    @Thebasicmaker Před 3 lety

    What arduino model is that board?

  • @JarppaGuru
    @JarppaGuru Před 7 měsíci

    raising clock boom! better read down clock same data is there and settled down lol