MOSFET as level shifter - Page 1
Forum section: electronics / beginners

author: ptrn
author_rank: Contributor
timestamp: March 08, 2023, 01:35:55 pm
content: Hi all,When using a MOSFET for level shifting, what are the characteristics I should look for? I want to shift SPI signals from 3.3 to 2.5 volts at 2 MHz.I already have a PCB manufactured for a project, but I'm having some trouble with erroneous data. The footprint is SOT-523. I've tried with Diodes 2N7002T-7-F, a part I had from a previous project. Is there something that screams wrong with this part?https://www.lcsc.com/product-detail/MOSFETs_Diodes-Incorporated-2N7002T-7-F_C139445.htmlIt looks like the Rds resistance is quite high and that 2.5 volts at the gate might be a bit low for this part?I've bodge-soldered in a BSS138 and that works without problems.The circuit consists of an ATMega328P directly into the level shifter with pullups before and after the MOSFET, and then onwards to the other IC.I'd love to hear your thoughts, all help is appreciated.Thanks

author: shapirus
author_rank: Super Contributor
timestamp: March 08, 2023, 01:58:55 pm
content: Have you actually verified, using a signal generator and an oscilloscope, that your circuit works?I am pretty sure that it, as it is shown, will stop working somewhere in the few hundreds of kHz range, even if the gate voltage is not an issue, i.e., at a higher voltage. It'll need a much lower pull-up resistor value to work in the MHz range.There are specialized ICs for level shifting.MOSFET driver ICs can also be used for this.There are also magnetic isolators designed with SPI in mind that can handle the frequency you need and which can be used as level shifters (not sure however if ones that can work at 2.5V exist; I had experience with 5V<->3.3V).And yes, 2.5V can be a challenge for both discrete parts and ICs. You'll need to look for something that can work at this level.p.s. now that I take another look at the circuit, I think it won't work at all. Maybe I haven't fully woken up yet, but... Have you actually tried it in hardware and/or simulation?

author: ptrn
author_rank: Contributor
timestamp: March 08, 2023, 02:17:40 pm
content: Yes, I've looked at it through an oscilloscope, see image below. This is on the MISO line, from 2.5 to 3.3 volts. I see now that the 3.3 volt signal is quite slow to rise up to 3.3 volt.Can you please share some insight into why this wouldn't work? And what should the pullup values be given this circuit?I've tried running the SPI bus at 250 kHz, and the results are exactly the same. Again, with BSS138 it works.On the next PCB I will for sure use a specialized level shifter IC.Thanks

author: Peabody
author_rank: Super Contributor
timestamp: March 08, 2023, 04:21:37 pm
content: If the board is already done, it probably doesn't matter, but your circuit is a bidirectional level shifter, and none of the SPI lines are bidirectional. The MISO line in particular probably doesn't need shifting at all since 2.5V should be interpreted as high in a 3.3V system. That's assuming the master is on the 3.3V side. The other three SPI lines would probably work with a diode and a pullup resistor, although the mosfet gives a lower low.I think the problem with the 2N7002 is the high threshold voltage. The BSS138 is much lower. I don't think RDSon makes any difference. You're adding a couple ohms resistance in series with a net 5K of pullup resistance - not likely to matter.

author: shapirus
author_rank: Super Contributor
timestamp: March 08, 2023, 04:23:52 pm
content: I may've been wrong. I didn't pay enough attention to looking carefully at your circuit, thinking it was like something I tried myself in the past which didn't work well.So I'm retracting that and now I can only confirm the obvious: yes, 2.5V is too low for a typical MOSFET to even begin to conduct, they usually need Vgs well above 3V. Regarding your particular circuit, I now want to try it myself. Live and learn.