Skip to content

Raspberry Pi Pico (RP2040) Level Shifting (3.3V ‐ 5V) to interface with other ICs

Neil Enns edited this page Sep 5, 2023 · 8 revisions

Introduction

This page describes techniques to shift the logic levels of a microcontroller running at 3.3 V supply to interface with other ICs running at 5.0 V supply.

The main focus is Raspberry Pi Pico boards or custom boards using the RP2040 microcontroller. But the same techniques can be applied to other microcontrollers and boards running at 3.3 V as well.

Tutorial

RP2040 output voltages

Mikrocontrollers like the Raspberry Pi RP2040 cannot be powered with a 5 V supply voltage. They require a regulated supply voltage of 3.3 V (they can actually be operated with as little as 1.8 V, but 3.3 V are typical for many applications). Due to this supply voltage, the I/O pins also operate at 3.3 V levels. The RP2040 datasheet provides the electrical specifications of the output voltages if a pin (configured as an output) is driven HIGH: image image It can be seen that even at 3.3 V supply, the output voltage at a HIGH logic level can be as low as 2.62 V.

This is too low for many external ICs to be safely detected as HIGH logic level.

Standard Logic Families

Texas Instruments provides a guideline about the different "logic levels" (e.g. CMOS, TTL) or "logic families" (HC, HCT). image

As the image shows, 5V TTL ICs (e.g. 74HCTxxx) will accept the output voltage of the RP2040, since they require only 2.0 V as "input high voltage" VIH. 5V CMOS ICs (e.g. 74HCxxx) will not (safely) accept the output voltage of the RP2040, since they require 3.5 V as "input high voltage" VIH. These values are "worst case" values. This means, in reality it can work, but not reliable.

Example: MAX7219

The MAX7219 is a very common IC used to control 7-Segment displays. A look in the datasheet reveals, that it requires a supply voltage of 4.0 V to 5.5 V. Typically, the user will supply it with 5.0 V (e.g. from USB). The datasheet also tells us, that the device will requires (in worst case) 3.5 V as "input high voltage" VIH to detect a high level input voltage. image

(Note: the same is true for similar ICs, such as XL7219)

The SN74LVC4245APWR "OCTAL BUS TRANSCEIVER AND 3.3-V TO 5-V SHIFTER WITH 3-STATE OUTPUTS" can help. This IC has two power supplies, VCCA and VCCB. From the datasheet: This 8-bit (octal) noninverting bus transceiver contains two separate supply rails; B port has VCCB, which is set at 3.3 V, and A port has VCCA, which is set at 5 V. This allows for translation from a 3.3-V to a 5-V environment, and vice versa.

That means the IC can be used similar to this image: image

Note: All unused inputs of the device must be held at the associated VCC or GND to ensure proper device operation. Since only three signals have to be converted, LOAD, DATA and CLOCK, there will be five remaining input channels, to which this requirement applies (unless they are used for other purposes).

Also other level shift ICs can be used, e.g. TXS0104ERGYR. However, care must be taken, since not all different ICs have the same assignment of VCCA and VCCB. In TXS0104ERGYR, the VCCA must be the 3.3 V supply and VCCB the 5.0 V.

Example: I2C

NXP has a great Application Note on how to do level shifting for I2C signals. Level shifting of I2C signals is different compared to "simple" output signals, since I2C is bidirectional, where both devices can drive the same signal line. One simple solution is using small signal MOSFETs for level shifting: image

A variety of ready-to-use level shifters based on that approach (and commonly using BSS138 MOSFETs) are available ("4-channel I2C-safe Bi-directional Logic Level Converter").

Installation

User Interface

Examples and tutorials

MSFS2020

X-Plane

Workshops

Community Boards & Devices

Additional Information

Firmware

Clone this wiki locally