ZX Interface Z - The Hardware, part 3

Let's interact

Welcome to the third part of the ZX Interface Z hardware overview. On the first part we looked with some detail at the expansion connector and the power supplies, the second part focused on the voltage level converters and the back connector. In this blog post we will look at the user interface and the SD card.

The buttons

The Interface Z has 3 buttons that can be used to control the Interface. One of the buttons is tied to an hard reset, which will reset the ESP32, causing the FPGA to be reprogrammed and the ZX Spectrum to also reset accordingly. Two other buttons exist, which are software controlled, but one of them has also an hidden purpose.

Some of these buttons (S1 and S2) include an hardware low-pass filter, comprised by the pull-up resistor and the capacitor to the ground. This helps to avoid excessive bouncing when the switch is pressed or released. The S3 switch does not include a low-pass filter, and delegates the debouncing to software.
All three buttons are fed into ESP32. 

On the board we use a different nomenclature for these buttons. S1 is called RST, S2 is called IO0 and S3 is called "USR". The S3 (USR) button is physically taller than the other two buttons, since it will be used more frequently.


 

The first button (S1) is conneted to the ESP_EN line, which is the ESP32 reset, active low. When the button is pressed, the ESP32 will reset.
The second (S2) and third (S3) buttons are availiable for use by the ESP32 software, and their behaviour might change on different revisions of the software. For the current version, pressing S3 will trigger an NMI to the ZX Spectrum, forcing it to enter our custom ROM. Pressing S2 for a long period (>1 second) will trigger loading of the debugging ROM (currently Retroleum Diag ROM) in case you want to debug your ZX Spectrum system. Short pulses on S2 are currently ignored.
Switch S2 has also a dual-purpose: if S2 is pressed, and while pressed the system is reset using S1, then the ESP32 will enter firmware upgrade mode via USB. We will look at this later on a future blog post.

We all love LEDs

Using LEDs to convey status information is not only useful, but also adds glamour to any hardware project. The ZX Interface Z has quite a few of them, in fact a total of 6 LEDs are present on the board. All LEDs are SMD high brightness, and their color varies according to its purpose.



All the LED include a current-limiting resistor of 2.2KΩ. Since they are high-brightness LEDs, they will be perfectly visible with a very low current flowing through them. This helps saving power.

Starting with LED3, this is a regular RED LED which will light up when the board is powered correctly. It sits on the lower-left side of the board.

Two other LEDs (LED2 and LED1) are placed near the user buttons. LED1 is driven by the ESP32, and it's used to indicate proper operation or internal errors. A normal 1-second flash will indicate that the software is running OK, a faster flash will indicate internal errors.

LED2 and the other 3 LEDs (FLED0, 1 and 2) are driven by the FPGA. The "FLED" LEDs are located at the lower-right side of the board. The use of LED2 and the FLEDs is still to be defined. On the current FPGA version, they are used to provide debug information such as if the ZX Spectrum is executing a custom ROM or not.

The SD card

ESP32 includes a SDIO driver for SD card, which is pretty fast, using all 4 data lines available to increase speed. 

So, all we need to do is connect the SD card to the ESP32, and it should work, right ?
No, not quite right. There are a few nuances that we need to take care of, let's look at them in detail.

For proper operation, the SD card in SDIO mode requires pull-ups on the data, cmd and clock lines. As you can see above, and connected directly to the SD card lines we have pullups on the detection line (DET, which is a regular IO on the ESP32), D1, D3, CMD and CK. What we don't have there is a direct pullup on the D0 and D2 lines. Why not, you may wonder, and what is that circuit below connected to D0 and D2?

Again, the D0 and D2 lines have a dual-purpose on the ESP32 side. They are connected to IO2 and IO12, respectively. These pins have a special meaning when the ESP32 is booting, and they have to be dealt differently. 

IO2 is used to enable the serial bootloader, and needs to be floating or driven low for us to be able to program the ESP32 through the on-board USB port. We cannot have a pull-up directly on this line.
IO12 (also known as MTDI) is used when ESP32 is starting to select the FLASH chip voltage (the FLASH chip is located inside the ESP32 module, and it's a 3.3V device). When MTDI is high on boot, 1.8V will be selected as the FLASH voltage, which will cause the ESP32 not to boot at all from FLASH. Again, we cannot have a pull-up directly on this line.

Summarizing, we cannot have pull ups on these lines when booting. However, we need the pullups when we enable the SD card, and the internal pullups on ESP32 are too weak, so external pullups are needed for proper SD operation.

We accomplish this by using a pair of P-Channel MOSFETs, one for each line, and driven by another ESP32 signal (PULLUP_EN, connected to IO33). When ESP32 starts this line is floating, so R28 pulls both MOSFET gates to +3.3V. This causes the MOSFETs to be "open", since the voltage between the source (connected to +3.3V) and the gate is aroud zero volts. Once the system starts, we activate the PULLUP_EN and connect it to ground. This causes the MOSFET gates to be at 0V, hence presenting a voltage difference of about -3.3V between the source and the gate, which then causes the MOSFET to "close", connecting R33 and R29 resistors between +3V3 and D0 and D2, respectively.

What's next?

We looked at the buttons, LEDs and SD card. On next blog posts, we will look in detail into these areas of the hardware:

  • Debugging and the USB-Serial programmer
  • ESP32 module
  • FPGA (*)
  • USB Host
  • SDRAM (memory)
(*) For the FPGA also a series of blog posts will explain in detail what goes around inside. Which is a lot. Quite a lot.

Hope you enjoyed this third blog post. Please leave any comments here or on the facebook page at https://www.facebook.com/zxinterfacez.

Comments

Popular posts from this blog

ZX Interface Z - The Hardware, part 1

ZX Interface Z - The Hardware, part 2