It is usually safe to assume that signals inside the microcontroller are straightforward logical zeros and ones although there are a few exceptions to this comfortable situation, such as the output of a comparator (see the section “Comparator_A” on page 371). Outside the microcontroller there is no escape from the fact that the real world is analog. This raises many issues, of which the most basic is the question, What analog voltages correspond to the digital values 0 and 1? Take VSS = 0 for clarity. The precise input voltages Vin that correspond to logical 0 and 1 depend on the technology but typical values for CMOS are

  1. Inputs of 0 to 0.3VCC give logic 0.
  2. Inputs of 0.7VCC to VCC give logic 1.

These are symmetric. The output voltage Vout for CMOS is typically below 0.1VCC for a logical 0 and above 0.9VCC for a logical 1. This is again symmetric and the large gap between the ranges for logical 0 and 1 means that CMOS is relatively insensitive to noise.

The logical value is undefined for an input that lies in the transition region between the two ranges, which is typically 0.3VCC to 0.7VCC for CMOS. Inputs in this range also cause an excessive current to flow through the input buffer, as shown in Figure 7.2(c). The apparent logical value as seen from inside the microcontroller may also oscillate wildly between 0 and 1.

The voltage on inputs should therefore pass rapidly through the transition zone. This is particularly important for inputs that generate interrupts or provide clocks (to a timer, for instance). An excellent feature of the MSP430 is that its inputs are provided with Schmitt triggers, which eliminate many of these problems. This includes the standard port inputs, which also protects their interrupts. Other digital inputs, such as the external clock to the timer, also pass through the Schmitt triggers. The details are shown in Port pin schematics in the data sheets. Figure 7.4 shows the output voltage as a function of the input voltage for a conventional buffer and a Schmitt trigger. The major difference is that a Schmitt trigger displays hysteresis. This is most easily explained by looking at the response to a slow triangular, wave on the input in Figure 7.4(c).The input and output are initially at 0 voltage and the input voltage rises gradually. The output remains safely in the range for logical 0 until the input passes through the upper

Positive-going threshold voltage VIT+ at (i). At this point the output jumps abruptly to a value that is well inside the range for a logical 1. It stays here while the input continues to rise and after it has started to fall again. The output remains at a logical 1 even after the input has fallen through VIT+ and does not change until the input crosses the lower threshold voltage VIT− at (ii). At this point the output jumps to a logical 0 and remains here as the input falls further.

The second half of the plot shows the effect of (rather fanciful) noise on the input. The output jumps from 0 to 1 when the input first goes above VIT+ at (iii). The noise pulls the input back down below this threshold but the output remains cleanly at 1. Similarly, on thedownward half of the wave, the output falls from 1 to 0 at point (iv) when the input first falls below VIT− and is not affected by fluctuations that take the input back above this threshold. Thus a Schmitt trigger has two desirable effects:

  1. It turns slowly varying inputs, which might cause problems while they pass slowly through the undefined range of input voltages, into abrupt, clean logical transitions. It eliminates the effect of noise on the input, provided that it is not large enough to span the gap between the upward and downward thresholds.
  2. Schmitt triggers have many other applications. A simple oscillator can be made by adding a resistor and capacitor, for instance.

Another analog aspect of the inputs is that a small current flows into or out of the pin.

Ideally this would be 0 because the gates of MOSFETs act like capacitors but in reality the capacitors leak slightly, as do the input protection diodes. Of course the circuit associated with each pin is much more complicated than a simple inverter too. Having said all that, the pins of the MPS430 have a low input leakage current, below ±50nA. This is roughly equivalent to a resistance of 50M_ and means that leakage should rarely cause a serious drop in voltage across a resistor in series with the input. The leakage current would not drop more than ±0.1V across a 2M_ resistor, for example. This allows large pull-up resistors to be used to save current, although the input may then become sensitive to noise.

The low leakage current is also important if the input is used to detect the voltage on a small capacitor (a few pF). This arises in touch sensors, which are also mentioned in the section “Capacitative Touch Sensing with Comparator_A” on page 391. Finally, low leakage contributes to a long battery life, particularly in devices with over 100 pins.

Before leaving this topic, let us look more closely at the way in which thresholds and other parameters are specified in the data sheet. Table 7.1 shows a small extract for the F20xx. There is a minimum and maximum for each of the two threshold voltages. When is each important? Suppose that the input is initially at VSS:

  1. The system should not respond to noise on the input, so any fluctuations in voltage must be kept below the threshold VIT+. In this case we should choose the minimum value of 1.35V to ensure that the input is never triggered.
  2. On the other hand, we want to guarantee that the microcontroller responds when the desired signal appears on the input.We must ensure that the input goes above the maximum value of 2.25V to be certain that the Schmitt input is triggered.