-
-
Notifications
You must be signed in to change notification settings - Fork 107
Raspberry Pi Pico (RP2040) Level Shifting (3.3V ‐ 5V) to interface with other ICs
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.
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: 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.
Texas Instruments provides a guideline about the different "logic levels" (e.g. CMOS, TTL) or "logic families" (HC, HCT).
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.
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.
(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:
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.
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:
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").
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
- MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards