Skip to content
Forged in Barberton, Ohio · Since 1983 Counter: +1 (330) 555-0142

How to drive a 0.39 inch micro OLED with an FPGA?

aBy admin||Great American Tool

To drive a 0.39 inch micro OLED with an FPGA, you need to interface the FPGA’s I/O pins with the display’s communication protocol, typically MIPI DSI or SPI, and generate the necessary timing signals to refresh the pixels at the required frame rate. This specific display, a 0.39 inch 1920x1080 micro oled display, uses a MIPI DSI interface with four lanes, which demands a high-speed differential signaling scheme that FPGAs are well-suited for due to their built-in SERDES blocks. The key is to configure the FPGA as a master controller that sends pixel data, synchronization pulses, and clock signals to the OLED driver IC, often a chip like the Solomon Systech SSD1351 or similar, which handles the actual pixel addressing. You’ll need to set up a PLL inside the FPGA to generate the pixel clock, typically around 160 MHz for a 60 Hz refresh rate on a 1920x1080 resolution, though this can vary based on blanking intervals. The MIPI DSI physical layer requires differential pairs for data and clock, so you must route these signals carefully on the PCB to maintain signal integrity, with impedance matching around 100 ohms. For initial setup, you can use the I2C interface to configure the display’s registers, like brightness, contrast, and sleep mode, before switching to MIPI for high-speed video streaming. The FPGA’s logic should include a frame buffer, either in block RAM or external DDR memory, to store the image data, as the micro OLED’s resolution demands a significant amount of memory—1920x1080 pixels at 24-bit color depth equals about 6.2 MB per frame, which exceeds most FPGA on-chip memory, so you’ll likely need an external SDRAM or DDR3 chip. The timing controller must generate horizontal and vertical sync signals, along with data enable, to match the display’s specifications, which you can find in the datasheet, typically with a horizontal front porch of 10 pixels, sync width of 20 pixels, and back porch of 30 pixels, and similar vertical parameters. The MIPI DSI protocol uses packets, so you’ll need to implement a packetizer in the FPGA that wraps pixel data into long packets, with header and checksum bytes, and sends them over the lanes at a data rate of around 800 Mbps per lane for a 60 Hz refresh. Power supply is critical: the micro OLED requires 1.8V for the I/O and 3.3V for the analog circuitry, plus a negative voltage for the OLED bias, often around -2.5V, which you can generate with a DC-DC converter controlled by the FPGA via GPIO. The FPGA’s logic utilization for a basic driver is moderate—around 5,000 to 10,000 LUTs for a simple framebuffer controller with MIPI DSI PHY, but this scales up if you add features like image processing or scaling. For testing, you can start with a pattern generator in the FPGA, like a color bar or checkerboard, to verify the display’s response without needing external memory. The MIPI DSI physical layer implementation in FPGAs often uses the device’s high-speed transceivers, such as Xilinx’s GTP or GTH, or Intel’s LVDS SERDES, which can handle the 800 Mbps per lane data rate, but you must ensure the transceiver reference clock is accurate, typically 25 MHz multiplied by a PLL to 200 MHz for the transceiver core. The I2C interface for configuration runs at 400 kHz, and you can use the FPGA’s soft-core processor, like MicroBlaze, to handle the initialization sequence, which includes setting the display to exit sleep mode, configuring the pixel format to 24-bit RGB, and enabling the MIPI interface. The display’s datasheet will specify the exact register values, such as setting the column address range to 0 to 1919 and row address range to 0 to 1079, and you must write these via I2C before starting the MIPI stream. The FPGA’s role is to maintain a continuous stream of pixel data, as the micro OLED has no internal frame buffer, so any interruption in the data stream will cause the display to go blank or show artifacts. The timing for MIPI DSI includes a low-power mode for control signals and a high-speed mode for data, so your FPGA design must handle the transition between these modes, typically by sending a low-power data type like 0x39 for the packet header, then switching to high-speed for the data payload. The number of lanes used can be configured in the display’s register, and for a 1920x1080 resolution at 60 Hz, four lanes are necessary to keep the data rate manageable, as using two lanes would require a 1.6 Gbps per lane rate, which is possible but more challenging for PCB layout. The FPGA’s I/O standards must be set to LVDS or HSTL for the MIPI signals, with the differential swing adjusted to around 200 mV, as per the MIPI specification. The clock lane runs at half the data rate, so for an 800 Mbps data rate, the clock is 400 MHz, and you must generate a differential clock with a 50% duty cycle. The FPGA’s PLL can generate this clock from a common reference, but you need to ensure the jitter is below 100 ps to avoid data errors. The display’s power-up sequence is critical: you must apply the I/O voltage first, then the analog voltage, then the negative bias, and finally enable the MIPI interface, with delays of at least 10 ms between each step, which the FPGA can control via GPIOs connected to the power regulators. The micro OLED’s pixel structure is active matrix, so each pixel has a thin-film transistor that stores the charge, but the refresh rate must be maintained to prevent flicker, and the FPGA’s frame rate should be locked to the display’s internal oscillator, which you can read via I2C. The MIPI DSI specification defines a video mode where the display expects continuous data, so your FPGA must send a blanking packet during the horizontal and vertical blanking intervals, which contain no pixel data but maintain the link. The blanking interval durations are specified in the datasheet, typically with a horizontal blanking total of 100 pixels and vertical blanking total of 10 lines, which affects the total pixel clock calculation. For a 60 Hz refresh, the total pixel clock is (1920 + 100) * (1080 + 10) * 60 = 132.0 MHz, but you may need to round up to 160 MHz to account for additional overhead. The FPGA’s internal memory for a line buffer is essential if you’re generating the image from a source like a camera or CPU, as you can store one line of pixels (1920 pixels * 3 bytes = 5.76 KB) and then send it via MIPI, but for full frame, you need external memory. The external memory interface, like DDR3, requires a separate controller in the FPGA, which can be complex, but many FPGA vendors offer IP cores for this, such as Xilinx’s MIG or Intel’s UniPHY. The DDR3 controller must be configured for a burst length of 8 and a data width of 16 or 32 bits, and the FPGA’s logic must read the data in the correct order to match the scanning direction of the display, which is typically left to right, top to bottom. The MIPI DSI packetizer in the FPGA must handle the data type, such as 0x3E for RGB888, and pack the pixels into 32-bit words for the transceiver. The transceiver’s serializer converts the parallel data to serial bits, and you must ensure the byte ordering is correct, with the least significant byte first for MIPI. The display’s datasheet will specify the exact lane mapping, such as lane 0 for data, lane 1 for clock, and so on, and you must route the FPGA’s transceiver outputs to the correct pins on the display connector. The PCB layout for the MIPI signals must have controlled impedance of 100 ohms differential, with trace lengths matched within 5 mm to avoid skew, and the FPGA’s transceiver has built-in deskew capabilities that can compensate for small mismatches. The power supply for the FPGA must be clean, with separate regulators for the core voltage (1.0V or 1.2V), the transceiver voltage (1.8V), and the I/O voltage (3.3V), and the micro OLED’s power supply must be isolated from the FPGA’s digital noise to prevent image artifacts. The FPGA’s configuration memory, typically flash, stores the bitstream that includes the MIPI controller, and you can update it via JTAG or SPI. The initial verification of the display can be done by sending a simple pattern like a single color, then a gradient, and then a full image, to check for any data corruption. The MIPI DSI link must be trained, which involves sending a low-power pattern to align the lanes, and the FPGA’s PHY must handle this automatically if you use a vendor IP core. The display’s sleep mode can be controlled via I2C, and the FPGA can put the display to sleep when not in use to save power, which is critical for battery-powered applications like AR glasses. The micro OLED’s brightness is controlled by a register that sets the current, and you can adjust it via I2C, but the FPGA must also manage the PWM if the display supports it. The temperature range of the micro OLED is typically -20 to 70 degrees Celsius, and the FPGA must monitor the temperature via an external sensor to adjust the display’s bias voltage if needed, as the OLED efficiency changes with temperature. The MIPI DSI interface can also support command mode, where the display has its own frame buffer, but for this 0.39 inch display, it’s likely video mode only, so the FPGA must stream continuously. The FPGA’s logic for the MIPI DSI controller can be implemented using a state machine that handles the initialization, blanking, and data transmission, and you can find open-source examples for Xilinx or Intel FPGAs. The data rate calculation for the MIPI lanes is based on the resolution and frame rate, and for 1920x1080 at 60 Hz with 24-bit color, the total data rate is 1920 * 1080 * 60 * 24 = 2.99 Gbps, which divided by 4 lanes gives 747 Mbps per lane, so you can set the transceiver to 800 Mbps for margin. The FPGA’s transceiver must be configured for the MIPI DSI physical layer, which uses a 8b/10b encoding, so the raw data rate is 800 Mbps * 10/8 = 1 Gbps per lane, but the transceiver handles this internally. The clock lane runs at 400 MHz, and the FPGA’s PLL must generate this from a 25 MHz reference, which requires a multiplication factor of 16. The MIPI DSI specification requires a minimum of 100 us for the low-power mode to high-speed mode transition, which the FPGA must implement in the timing controller. The display’s register set includes a command for setting the pixel format, and you must write 0x3A followed by 0x77 for 24-bit RGB, which is a common setting. The FPGA’s I2C controller must be a master, and you can use a simple bit-banging approach or a dedicated IP core, but the bit-banging is easier for low-speed configuration. The I2C address for the display is typically 0x3C for write and 0x3D for read, but check the datasheet. The MIPI DSI interface also requires a reset pin, which the FPGA must toggle low for at least 10 us and then high to initialize the display. The FPGA’s GPIOs can control the reset, power enable, and backlight if present, but the micro OLED has no backlight as it’s emissive. The display’s contrast can be adjusted by writing to the contrast register, which is a byte value from 0 to 255, and the FPGA can set this based on ambient light sensor input. The FPGA’s frame buffer must be updated at the correct rate, and if you’re using external memory, you need a DMA controller to read the data and feed it to the MIPI transmitter. The DMA controller can be a simple state machine that reads from the DDR3 memory in bursts and writes to a FIFO, which then feeds the MIPI packetizer. The FIFO depth must be at least one line of pixels, so 5.76 KB, but a depth of 16 KB is safer to handle memory latency. The DDR3 memory clock is typically 400 MHz for a 800 MHz data rate, and the FPGA’s memory controller must handle the refresh cycles. The micro OLED’s resolution of 1920x1080 is high for a 0.39 inch display, which gives a pixel density of over 5000 PPI, so the image quality is extremely sharp, but the FPGA must handle the data rate without errors. The MIPI DSI interface can also support video modes with different pixel formats, such as RGB565, but for best quality, use RGB888. The FPGA’s logic for the MIPI DSI PHY can be implemented using the SERDES blocks in the FPGA, which are designed for high-speed serial interfaces. The SERDES block in a Xilinx 7-series FPGA can handle up to 12.5 Gbps, so 800 Mbps is well within its range. The FPGA’s transceiver must be configured for the MIPI DSI standard, which uses a differential voltage swing of 200 mV, and the transceiver’s output swing can be adjusted via the FPGA’s configuration registers. The display’s datasheet will specify the maximum cable length, which is typically a few inches for MIPI, so the FPGA must be close to the display on the PCB. The FPGA’s power consumption for driving the display is around 1-2 watts for the FPGA itself, plus the display’s power of about 0.5 watts, so total power is manageable for portable devices. The FPGA’s thermal management must be considered, as the transceiver can heat up, and a heat sink or fan may be needed for high ambient temperatures. The micro OLED’s lifetime is typically 10,000 hours, and the FPGA can monitor the usage time and adjust the brightness to extend the life. The MIPI DSI interface can also support error detection, such as CRC, and the FPGA can check the display’s acknowledgment packets to ensure data integrity. The FPGA’s firmware can be updated over the air if the device has a network connection, which is useful for field upgrades. The display’s viewing angle is 160 degrees, and the FPGA can adjust the gamma curve via I2C to compensate for viewing angle variations. The FPGA’s implementation of the MIPI DSI controller can be done in VHDL or Verilog, and you can use the vendor’s IP core for the transceiver, but you must write the application layer logic yourself. The test setup for the FPGA and micro OLED includes a logic analyzer to probe the MIPI signals, but you can also use the FPGA’s internal debug cores like ChipScope or SignalTap. The MIPI DSI signals are differential, so you need a differential probe or a single-ended probe with a ground reference for the logic analyzer. The FPGA’s configuration bitstream can be generated using the vendor’s software, and you must set the transceiver parameters like the data rate, reference clock, and loopback settings. The display’s initialization sequence must be written in the FPGA’s ROM or loaded from an external memory, and you can use a state machine to step through the commands. The MIPI DSI interface also supports a video mode with a continuous clock, which is easier to implement than a clock that stops during blanking. The FPGA’s PLL must be locked before the MIPI interface is enabled, and you can monitor the lock status via a GPIO. The display’s power supply sequence must be followed exactly, or the display may be damaged, so the FPGA must control the power regulators with delays. The micro OLED’s negative bias voltage can be generated by a charge pump controlled by the FPGA, and you must ensure the voltage is within the display’s specification, typically -2.5V to -3.0V. The FPGA’s I/O pins for the MIPI interface must be configured with the correct slew rate and drive strength to minimize reflections. The PCB trace length for the MIPI signals must be matched to within 5 mm, and the FPGA’s transceiver has a deskew feature that can compensate for up to 100 ps of skew. The display’s datasheet will provide the exact timing parameters for the MIPI interface, such as the horizontal back porch, front porch, and sync width, which you must use in the FPGA’s timing generator. The FPGA’s logic for the timing generator can be a counter that increments with each pixel clock and generates the sync signals when the counter reaches the specified values. The horizontal sync signal is active low for MIPI, and the FPGA must invert the signal if the display expects active high. The vertical sync signal is also active low, and the FPGA must generate it after each frame. The data enable signal must be high during the active video area and low during the blanking intervals. The MIPI DSI interface uses a packet-based protocol, so the FPGA must send a packet header before each line of pixels, which includes the data type and the pixel count. The packet header is 4 bytes, and the FPGA must calculate the checksum for the header and the data. The checksum is a simple XOR of the bytes, and the FPGA can calculate it in hardware. The MIPI DSI interface also supports a short packet for commands, which the FPGA can use to send commands to the display during the vertical blanking interval. The display’s register set includes commands for setting the display on, sleep out, and brightness, which the FPGA can send via short packets. The FPGA’s MIPI controller must handle the transition from low-power mode to high-speed mode, which involves sending a low-power data type followed by a high-speed data type. The transition time is typically 100 us, and the FPGA must insert a delay in the state machine. The display’s datasheet will specify the exact timing for the transition, and you must follow it to avoid data corruption. The FPGA’s transceiver must be configured for the MIPI DSI standard, which uses a 8b/10b encoding, so the transceiver must be set to 8b/10b mode. The transceiver’s reference clock must be clean, and the FPGA’s PLL must generate the transceiver clock from


a

About the author

admin

Writing from the floor of the Barberton forge, where the steel is hot and the warranty still means something.