Author Topic: STM32 and 5v devices: Your favorite level shifter? Or open drain with pullup?  (Read 13241 times)

0 Members and 1 Guest are viewing this topic.

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
I have a working build system for STM32F103 and STM32F030, and have hardware debugging. Now I am looking at porting my device libraries from STM8 to STM32. These include LED displays
 with the MAX7219 and TM1638 controllers, which require 5v Vdd and 0.7 Vdd high signal levels. I may also need those levels for the HD44780 LCD controllers.

Looking at the STM32F030 datasheet, most of the pins are "TTa" with a maximum voltage of 4.0, and a maximum injected current of 5ma. This implies to me that those pins are diode clamped to 4.0 volts and I am allowed to use a pullup resistor, up to 5ma. So if I use a 1k pullup to 5v and select open drain, the injected current would be 1ma (high) or 5ma (low). Question: Even if I MAY do this, is it a good idea?

A nicer option would be to use a level converter. Maybe a hex buffer in 74HCT? Is there a favorite choice for something this simple?

Thanks!
Currently developing embedded RISC-V. Recently STM32 and STM8. All are excellent choices. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1559
  • Country: us
  • Very dangerous - may attack at any time
Single: 74AHC[T]1G125
Quad: 74AHC[T]125
Octal: 74AHC[T]541
Single bidir: 74LVCH1T45
Octal bidir: 74LVC8T245

74AHC family can go from 5V to 3V3 when powered with 3V3.
74[A]HCT familty can go from 3V3 to 5V when powered from 5V.

« Last Edit: February 09, 2020, 05:20:33 pm by oPossum »
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3671
  • Country: gb
Looking at the STM32F030 datasheet, most of the pins are "TTa" with a maximum voltage of 4.0, and a maximum injected current of 5ma. This implies to me that those pins are diode clamped to 4.0 volts and I am allowed to use a pullup resistor, up to 5ma. So if I use a 1k pullup to 5v and select open drain, the injected current would be 1ma (high) or 5ma (low). Question: Even if I MAY do this, is it a good idea?

In short, no.  4 volts is the value given in the absolute maximum table.  As stated in the datasheet, these values are damage limits, and correct operation (or indeed any operation at all) is not guaranteed.  These pins will be tired to ground and Vdd via ESD protection diodes, and a good design will never deliberately forward bias these diodes since no safe maximum current is provided for normal operating conditions, only an absolute maximum.

For inputs you are in luck, many of the STM32 GPIO pins are 5v tolerant when configured as an input.  For 5v output logic you need some kind of level translation.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22435
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
In short, no.  4 volts is the value given in the absolute maximum table.  As stated in the datasheet, these values are damage limits, and correct operation (or indeed any operation at all) is not guaranteed.

The 5mA figure is functional, not damaging.

Note that analog functions may still be disrupted, especially ADC functions on respective pins.  These usually end up with a 0mA current injection limit.

As for level translation, a schottky clamp diode is a good idea, with a series resistor if necessary.  This allows you to use 5V CMOS into 3.3V inputs, or TTL directly (which pulls up to ~3.5V normally, so maybe kinda doesn't even really need the clamp diode, but it's nice to have).

Going the other way, 3.3V is a bit low for guaranteed 5V CMOS thresholds, but can be raised a bit with a voltage divider (series resistor from output to input, pullup from input to +5V), or is fine for TTL.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
I have a working build system for STM32F103 and STM32F030, and have hardware debugging. Now I am looking at porting my device libraries from STM8 to STM32. These include LED displays
 with the MAX7219 and TM1638 controllers, which require 5v Vdd and 0.7 Vdd high signal levels. I may also need those levels for the HD44780 LCD controllers.

Looking at the STM32F030 datasheet, most of the pins are "TTa" with a maximum voltage of 4.0, and a maximum injected current of 5ma. This implies to me that those pins are diode clamped to 4.0 volts and I am allowed to use a pullup resistor, up to 5ma. So if I use a 1k pullup to 5v and select open drain, the injected current would be 1ma (high) or 5ma (low). Question: Even if I MAY do this, is it a good idea?

A nicer option would be to use a level converter. Maybe a hex buffer in 74HCT? Is there a favorite choice for something this simple?

Thanks!

The STM32F103 electrical document (August 2015  DocID13587 Rev 17  page 1 of 117) has this to say:

"Up to 80 fast I/O ports 26/37/51/80 I/Os, all mappable on 16 external interrupt vectors and almost all 5 V-tolerant"

You need to use the "FT" (five volt tolerant) not "TTa" pins I think.
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3821
  • Country: us
Single: 74AHCT1G125
Quad: 74AHCT125
Octal: 74AHCT541
Single bidir: 74LVCH1T45
Octal bidir: 74LVC8T245

74AHCT family can go from 5V to 3V3 when powered with 3V3, or 3V3 to 5V when powered from 5V.

Don't you need to use 74AHC parts to go from 5V to 3.3V?  The 74AHCT datasheets don't say anything about 3.3V operation.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11484
  • Country: fi
One hack I have resorted to is to power the (CMOS) devices from 3.6V and 4.5V. Many 3V3 devices list 3.6V as the functional max, and many 5V devices list 4.5V as the functional min. Of course, you lose any margin against regulation inaccuracy. If you use adjustable regulators anyway, or find suitable parts easily, this is zero extra parts and no extra circuitry at all.

This way, high level of 3.6V is 80% of the Vdd=4.5V, above the typical 70%-ish CMOS threshold.

Of course, such a hack is more sensitive to noise, and note that when charging the line RC parasitics, the last few dozen millivolts takes the longest, hence you'd want to have some "overdrive" over the minimum reliable detection threshold.

Open drain with pull-up is obvious, but only works with 5V tolerant pins, so need to be careful with pin mapping. Also note that it's limiting the output impedance to somewhere around 1kOhm min, so maximum speed drops due to line capacitance.
« Last Edit: February 09, 2020, 07:19:32 am by Siwastaja »
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Usually the problem with open collector + pullups is the positive going edges, the negative ones are always fast enough. What you need to do is check your positive edges with the scope, and find the highest pullup R (4k7?) that can bring the pin HI quickly enough for the kind of signals you're dealing with. Slow signals can do with 10k that's for sure.
The further a society drifts from truth, the more it will hate those who speak it.
 

Offline rhodgesTopic starter

  • Frequent Contributor
  • **
  • Posts: 364
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Quote
You need to use the "FT" (five volt tolerant) not "TTa" pins I think.
I am working with SPI, and the stm32f030f4 only has 4 5v tolerant pins. The SPI pins are not.
I see the '103 does allow 5v on the 2 SPI devices, though. Maybe I should get SPI working with '103 first.
Currently developing embedded RISC-V. Recently STM32 and STM8. All are excellent choices. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Quote
You need to use the "FT" (five volt tolerant) not "TTa" pins I think.
I am working with SPI, and the stm32f030f4 only has 4 5v tolerant pins. The SPI pins are not.
I see the '103 does allow 5v on the 2 SPI devices, though. Maybe I should get SPI working with '103 first.

I use the STM32F051 in UFN32 and it has SPI1 available as FT in alternate function, or both in the 48 pin flat pack upwards. The F030 is a kind of cut down variant I think.

I doubt a lot would translate from the F103, so if your final target is the F030f4 I'd probably go with some level translator on it from the start. The F103 is a 16 years old now, and one has to be sure to read the errata :)
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1559
  • Country: us
  • Very dangerous - may attack at any time
74AHCT family can go from 5V to 3V3 when powered with 3V3, or 3V3 to 5V when powered from 5V.

Don't you need to use 74AHC parts to go from 5V to 3.3V?  The 74AHCT datasheets don't say anything about 3.3V operation.

Yep. Memory failed me again. Original post corrected.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3671
  • Country: gb
In short, no.  4 volts is the value given in the absolute maximum table.  As stated in the datasheet, these values are damage limits, and correct operation (or indeed any operation at all) is not guaranteed.

The 5mA figure is functional, not damaging.

Fair enough, I only saw the 5mA injected current value is listed in section 6.2 "Absolute maximum ratings".  The I/O current injection characteristics in 6.3 does suggest that things should mostly work at this value, but also states it should be avoided.
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1957
  • Country: gb
These are generally the options I've used many times: For 3.3V/3V to 5V I use HCT buffers (244, 541 for easy routing 8-bit busses).  For the other way, LCX (and LVC I believe), sometimes VHC but the VHC245 isn't 5V tolerant as its bidirectional - the output has a parasitic diode clamp to VCC.  For bidirectional low frequency signals I tend to use the cheap 2N7000 with pull ups.

HCT logic is still ubiquitous, and LCX is almost as common nowdays.
 

Online splin

  • Frequent Contributor
  • **
  • Posts: 999
  • Country: gb
TI do a large range of level translators starting at around $.05:

http://www.ti.com/logic-circuit/voltage-level-translation/products.html#sort=p1130;asc

Other manufacturers no doubt supply similar.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->