Digital Logic Levels
A less well-known fact about most digital circuits is their expected driving levels. That is, the level of voltage you are expected to use to form a digital high (logic 1) or digital low (logic 0).
Texas instruments has an awesome document for this. In short, here is the key information.
What this image shows is a nice clear representation of three things.
- Always drive a logic high in the red region
- Always drive a logic low in the red region
- Never drive a signal in the grey region.
This is for many reasons.
- To prevent noise from interfering with your logic levels
- To properly drive the underlying semiconductor (mainly CMOS)
- To allow tolerances inside the chip/semiconductor manufacturing process
There is one that is more important than them all. The excessive current that can damage CMOS devices.
One rule of thumb that if you follow you won't have any issues:
- If driving a 5V logic signal, always drive it over 4.5V, and sink to 0V.
- If driving a 3.3V logic signal, always drive it over 2.5V, and sink to 0V.
This ensures you are always driving a signal compatible with both logic types.
The main concern with mixing standards is driving a CMOS gate in the grey area.
Driving a 5V CMOS gate to 3.3V will draw 80 times more current than with the proper one and zero.
You can read about the serious issues with current, burn out and damaging CMOS circuits this way in this Analog article.
A huge amount of the time when you mix standards (primarily mixing TTL with CMOS devices) you almost never experience issues.
This is because even though the standards state for example TTL when driving high, you must drive higher than 2.4V in a 5V circuit, the circuit designer doesn't design the driving circuit to do just over that. In almost all cases they simply drive the circuit with 5V.
Similarly, when driving low, you typically just sink to ground and drive to 0V.
For that reason the logic type is often neglected in design, or simply forgotten. This can sometimes become a problem however. A perfect real world example is in the case of Game Gear Flash cartridges which I recently discovered had a technical issue in their design.
The Flash Gear Pro, and EverDrive both have the same design flaw where they drive the SMS pin of a CMOS gate in the Game Gear to 3.3V, not leaving it floating at 5V. This could causes permanent and excessive current 80 times higher than designed inside the Game Gear ASIC.
The Game Gear uses a Zilog Z80. This means the pins are CMOS logic, and so have excessive current when driven less than 4.4V and more than 0.5V.
In typical fashion, as mentioned previously, this doesn't cause any immediate or obvious issue. The Game Gear still works, nothing seems to get hot, everything runs as expected... until it doesn't. Some Game Gear CMOS gates have worse tolerance (they have to be pretty bad tolerance, but some are) and have the same glitched output.
A perfect example is using a version of the CleanScreen that I had specifically set to expect true CMOS logic (higher than 4.4V) on the SMS pin. This meant when used with a flash cart with this pin error, the SMS pin logic inside the CleanScreen would rapidly toggle between high and low (as with a CMOS logic gate if it so decides based on its tolerances).
The visual issue was easily fixed by changing the design of the CleanScreen to handle TTL logic levels (so 0.5V for low, and over 2.4V for high), but this now introduces several issues:
- We are not within standards of the designed system (the Game Gear), and our input pin is a standard hybrid expecting a non-standard input range from what other peripherals or the general system may run at. The Game Gear may interpret the CMOS logic differently than our TTL logic and cause the two to not work correctly in yet another way.
- Noise can now influence this pin in a correctly operating system (a real Master System game running correctly at 5V), by having noise on the rail lowering it to less than 3V (not that hard in older systems).
- We haven't fixed the several issues with the circuit design, the flash cart, or the current overdraw on the Game Gear.
The correct fix in this situation is to fix the flash cartridges to operate correctly with the same standards as the CleanScreen and Game Gear, along with all other peripherals, are designed to operate within.
The EverDrive uses a termination resistor trick, adding a 100ohm resistor between the 5V output of the Game Gear, to interface to the 3.3V logic of the FPGA.
This is for some reason a semi-common practise and recommended in some places. The thought of limiting the current to prevent damage to the3.3V tolerant pins.
This however is not ok. It is highly discouraged by makers of FPGA chips, who know much more about their devices than we do. Just read this app note from AMD and look under Termination Resistors.
īģŋ
A better recommendation is to also add a diode. But at this stage, just use a proper level shifter and do things right.