@mf2105 Well it kind of depends on the capacitance of your 3.3V input. The more capacitance it has, the slower your rise and fall times will be, and that’s not good for data integrity. There are ways to calculate it pretty easily but it depends on a lot of factors, so it’s really easiest just the take a look at your waveforms on an oscilloscope. If you don’t have one of those, then it’s probably best to over design your circuits… i.e., use a high speed method even if you don’t think you need it.
Depending on what’s driving your 5V to 3.3V level shifter, you can can increase the speed capability by lowering the resistor values. This lowers the overall impedance that is creating a time constant with your input capacitance.
Another effect of capacitance on your input is that the faster you switch it on and off, the lower it’s capacitive reactance will be, effectively reducing your signal to a point where your input doesn’t register it anymore. This is typically referred to as the the Cut-Off frequency of your RC circuit, and is calculated with Freq(cut-off) = 1 / (2 x π x R x C). Driving your RC circuit at this frequency will reduce your output voltage to about 70% of the input, based on the fact that the capacitive reactance is now forming a voltage divider with your series resistance. Series resistance is basically the Thevenized value of your resistor divider, which is simply the two resistors in parallel. 10k || 20k = 6.6k. STM32 general I/O capacitance is listed as 5pF. So the cut-off frequency would be: 1 / (2 x 3.141592 x 6600 x 0.000000000005) = ~4.8MHz.
Keep in mind 4.8MHz is the speed at which your output will be 70% less than your input (which in this case is 3.3V)… This means when your signal is high, it’s really only 3.3V x 0.7 = 2.31V.
Is that bad? Well it can be… let’s see… so we look at the minimum Vih (voltage input level high) needed for general I/O of the STM32. The equation is the craziest one I’ve seen (0.41 x (Vdd - 2V) + 1.3V) or 1.833V. So 2.31V is still above that, so it should register as high.
So it seems like up to 4.8MHz is ok… however… that’s not all you have to consider.
Your square waveform may not be so square anymore, and with rounded leading edges, you may have lower voltages at points where the hardware modules may sample the level of the input signal. This is especially true for any clocked signal, but also true for things like asynchronously clocked data like TTL UARTS (aka your serial driven stuff).
So without looking at it, I’d probably stay under 2Mhz with that resistor divider.
The fastest waveform you can make with 9600 Baud is a 0xAA or 0x55 pattern of 0b10101010 or 0b01010101. This is actually Baud / 2. Baud is essentially = Frequency for our TTL 8 N 1 None stuff.
So if we say 2MHz is the limit. Baud / 2 <= 2Mhz. or Baud = 2 x 2Mhz, 4,000,000 Baud.
So, you’re good! But always double check with a scope if you can!