To learn embedded systems, follow @I want to learn embedded systems, the gas station of embedded men.
01
MicroByte is a micro console that can run games from NES, GameBoy, GameBoy Color, Game Gear, and Sega Master System, all components designed within this 78 x 17 x 40 mm package.
Despite its small size, it conforms to the layout of SNES game boards and features operational buttons.
Additionally, it comes with a clear 1.3-inch IPS display to see all the details of the games.
Subsequent updates will include Python and Arduino libraries for development work beyond gaming.
Firmware, PCB design, and 3D files for the casing can be downloaded from the project repository: https://make.quwj.com/project/359
BOM list: https://github.com/jfm92/microByte_PCB/blob/main/microByte_BOM.xlsx
02
When starting an electronic project, a block diagram is usually created first, outlining the required functions and interactions of the project, followed by schematic design. On the schematic, components that meet the requirements are selected and electrically connected, and then the PCB layout design is done.
Finally, the position of each component’s footprint is set according to design rules and physical design guidelines.
The above is the original version based on a breadboard, and below is the final version.
This project will be developed with a modular approach, supported by schematic design and PCB layout design.
The project schematic and PCB layout are designed using Kicad, download link: https://github.com/jfm92/microByte_PCB/tree/5cb0fcf7a9658e331d677588a7f35327a7d491d7
To open it, simply install Kicad and double-click the .pro file.
03
First, choose an appropriate microcontroller; for this project, the ESP32 Wrover E module is selected.
This module/microcontroller features: 240 MHZ dual-core, 16 MB flash memory, 8 MB RAM, ultra-low-power co-processor, supports Wi-Fi and Bluetooth, and a full set of peripherals and GPIO, providing excellent emulation performance.
Refer to Espressif for design; the datasheet is as follows: https://www.espressif.com/sites/default/files/documentation/esp32-wrover-e_esp32-wrover-ie_datasheet_en.pdf
The schematic of the circuit board module:
In the middle is the ESP32 module connected to peripheral devices.
Pin 25 is the IO 0 pin. This pin is used to select the boot state of the device; it can flash new firmware or boot already flashed firmware. A high signal boots the already flashed firmware; a low signal enters boot mode and waits for new firmware.
Pin 3 is the enable pin (also known as reset). If this pin is high, the microcontroller will work; otherwise, it will not. To avoid signal bounce, there is an RC circuit (resistor/capacitor) here that generates a clean signal during board startup or transition to prevent accidental resets. Since this circuit does not have a reset button, it is not entirely necessary, but it is best to be cautious.
Pin 24 is the IO 2 pin, connected to a blue LED with a resistor, serving as a notification display.
Let’s take a look at pin 2 or VDD 3V3. This pin powers the chip with a voltage of 3.3 V. Note the parallel capacitors; these capacitors are decoupling capacitors used to clear parasitic interference.
Below is the PCB design layout and the key areas studied in the PCB board.
Additionally, related components should be kept as close as possible.
04
The USB transceiver is a chip that converts USB signals into serial, RS232, or other similar protocols. There are various models available on the market, here we use CH340C.
CH340C does not require an external clock like CH340G, is easy to use, and costs only a fraction of CP2102 or FT232.
As shown on the right side of the figure. Its design is very simple, with only one chip, two decoupling capacitors, and a 0-ohm resistor. If unsure whether a connection is necessary, this resistor can be used as a bridge.
On the right is a schematic of the USB-C connector. Its purpose is to connect to the PC and charge the battery. Using USB-C in PCB wiring is more challenging, as it requires adding dual connections that can be used with wires in any direction.
Tip: USB signals are parallel high-speed signals; they must be wired as parallel as possible to avoid crosstalk between signals and keep the signal lines close to the digital logic chips.
05
This section is divided into three parts: battery charging and protection circuit, power management, and battery level control.
Battery charging and protection circuit:
For Li-Po battery usage, safety is paramount; a proper constant current charging controller must be made to prevent charging above 4.2 V or discharging below 2.8 V to avoid damaging the battery.
TP4056 is a lithium polymer battery charger chip that provides constant linear voltage current and can set the charging current by modifying the resistance R2. Remember that the charging current should be about 25% of the battery capacity. This chip is connected to LED D1 to indicate the battery’s charging status.
FS312F-G is a battery protection circuit chip that disconnects the battery’s use if it detects overcharging or excessive discharge. This prevents battery damage.
FS8205 is a chip that integrates two MOSFET transistors to select circuit power; if the battery is within the appropriate range, it draws energy from the battery; if the device is connected to the USB port, it will directly use USB power.
Power management:
This module is a boost converter circuit that provides a constant voltage of 3.3 V. The maximum charging voltage for lithium batteries is 4.2 V, and the minimum safe voltage is 2.8 V. Therefore, a constant voltage is needed to avoid instability in the microcontroller or low brightness on the display.
To solve this issue, MT3608 is used, a configurable boost voltage converter. At the output of this circuit, the voltage is 4.2 V, higher than the 3.3 V required by the device, so the MCP1700 voltage converter is used to convert the voltage from 4.2 V to 3.3 V.
This solution may have issues of over-design or inefficiency, but it is the cheapest and most effective solution.
Battery level control:
Just like the voltage divider before the boost circuit. The voltage at this point will reach a maximum of 4.2 V, so a divider is designed to reduce it to 3.3 V to comply with the ESP32’s logic levels and connect it to the ADC GPIO to measure the analog level signal.
06
The SD card uses the SPI protocol, which is a bidirectional communication that enables high-speed communication. When using peripherals, there is no need to worry about crosstalk as its speed is not sufficient to generate a magnetic field (at least there are no issues here).
The circuit is also very simple, connecting each line to the MCU’s SPI GPIO and adding a pull-up resistor. This resistor is important to maintain a constant high level on the line and avoid intermediate level signals that may disrupt data transmission.
Here we also have our old friend, the decoupling capacitor.
07
Using ESP32, there are two ways to output audio. Checking the datasheet, you can use the integrated I2S to DAC converter or directly use the I2S peripheral.
The easiest way to get audio output is to use the I2S to DAC converter, as speakers can be directly connected to GPIO. If the audio volume is low, an analog audio amplifier can be used, which is very easy to implement. However, this solution also comes with some inconveniences. The DAC only uses 8 bits out of the 16 bits in I2S, meaning a lot of audio information will be lost, resulting in very poor audio quality.
I2S is a digital audio protocol that guarantees high-fidelity audio without quality loss or noise. But it requires a converter to convert the signals to analog and amplify them. Here, we use the MAX98357 audio amplifier.
This amplifier converts I2S signals to analog signals and amplifies them for direct use with speakers or headphones.
This amplifier/converter provides us with 6.4W of output power and has configurable output options—selecting between mono or stereo audio and impedance options.
Disclaimer: I am not very knowledgeable about audio, so some audio data may be incorrect and is for reference only.
08
ESP32 is a nice module, but it has a limited number of GPIO ports. But don’t worry, we have the TCA9555 solution.
TCA9555 is an I2C GPIO multiplexer. This device allows for up to 18 additional GPIOs. These GPIOs can be used as inputs or outputs and can be controlled or checked via I2C.
So with only two GPIOs (I2C SDA and I2C SCLK), we have 18 extra GPIOs! Delay is not an issue, as data can be read or written at up to 400 Khz, meaning 400,000 times per second!
Let’s take a look at the schematic. This multiplexer is used with I2C, so each signal needs to be pulled up to avoid noise on the line. It also has an interrupt pin, but it is not used.
I2C signals are SCL and SDA pins (19 and 20). The device’s address must be configured via hardware, which is done by setting the logic levels of pins A0, A1, and A2. There is only one I2C device here, so the address is given as 0x00.
Finally, all switch buttons are directly connected to the chip, and we set up pull-up or pull-down resistors via software, as this multiplexer has configurable internal resistors.
One interesting aspect of this device is the inductive buttons, which are PCB traces without silk screen layers, allowing rubber buttons with carbon film to be used as switch buttons. This is the regular configuration on game controllers. If you want to use it in your design, you can find it in the library that comes with the project.
09
The display features a 1.3-inch IPS screen with a resolution of 240 x 240 px, providing very nice colors and clear images. The communication protocol is SPI, allowing for frame rates of up to 70 FPS (as stated in the datasheet).
On the other hand, the backlight of the display can be controlled to select brightness levels. Control of the LED embedded in the display is done using a BS138 MOSFET transistor to complete the current control.
Completion
Now you can run this retro game console and start your journey of retro gaming memories!
The code used for the project can be downloaded from the project repository: https://make.quwj.com/project/359

What is over-the-air download technology? A must-watch for learning embedded systems!

What is it like to earn 20,000 a month at a research institute?

Why do they require proficiency in C/C++ when hiring microcontroller engineers?

Make a super mini balancing bicycle, fully open-source!