EE 22442 - Embedded Systems Fall 2013: Chapter Three
EE 22442 - Embedded Systems Fall 2013: Chapter Three
Introduction
This chapter now begins to move from theory to the practice of small-scale hardware design. The microcontroller core has internal data and address buses The microcontroller needs to be provided with a way of allowing that data flow to connect with the outside world Parallel input/output port. In this chapter we will learn about:
Why we need parallel input/output. How simple logic circuits can be developed to give a flexible interface between the microcontroller data bus and the outside world these are the parallel ports. How external devices can be connected to the parallel port. The parallel input/output available on the PIC 16F84A. The essential hardware features of the power supply and clock oscillator. The Microchip approach to power supply and oscillator, with the 16F84A.
To reduce wasted current when the switch is closed, the value of R should be high.
If it is too high, then the Logic 1 level may not be properly sustained. Need to evaluate the upper limit of the pullup resistor taking in consideration the input leakage current and logic thresholds. For PIC microcontrollers, pull-up values in the range 10100 k ohm are usually appropriate.
LEDs
For a single LED to be comfortably visible, it typically requires around 10mA of current. Brighter ones may require up to 20 mA, but special low-power devices (such as the high efficiency red) need as little as 1 or 2mA to be seen.
CMOS logic families have symmetrical outputs and can source or sink almost equally well, so either of these circuits can be applied. TTL logic can source little current but can sink a comparatively large amount, and therefore the configuration of Figure 3.9(b) is preferred in this case.
Current-limiting resistors
A current-limiting resistor must normally be included in series with the LED. This is calculated as shown below by considering the voltages in the circuit. Precise values are not usually required. An exception to the need for a series resistor, which must be cautiously applied, is when the logic is powered from a comparatively low voltage, and its internal output resistance itself forms an appropriate value for the current-limiting resistor.
16F84A Port B:
This is a general-purpose 8-bit bi-directional port The simplest bits, 0 to 3, are illustrated in Figure 3.10(a). Bits 4 to 7 of Port B are seen in Figure 3.10(b). They have a useful interrupt on change facility.
PORT B
PORTB - Continued
Four enhancements to the simple pin driver circuit we saw earlier: The incoming data is latched, rather than just its instantaneous value being read. The state of the TRIS latch can be read via the buffer controlled by the RD TRIS line. TRIS register acts as a normal read/write memory location, and the program can check if necessary the values previously stored there. Bit 0 is also the external interrupt input and has a Schmitt trigger interface. Weak pull-up resistors can be switched on for all port bits used as inputs. These can be applied to replace the resistor in circuits like in Figure 3.7(b). The pull-up is implemented with a p-channel MOSFET, seen at the top of the diagram. They are enabled for all port bits set as input by clearing the bit RBPU in the OPTION register. (This is seen memory-mapped in Figure 2.5 or in full in Figure 6.9.) Bits 4 to 7 of Port B are seen in Figure 3.10(b). They have a useful interrupt on change facility. As with the lower-numbered bits, the data value is latched as input data is read.
PORTA
Like Port B, this can be used as a general-purpose bi-directional digital port.
Power supply
The need for power, and its sources Traditionally, much logic circuitry is supplied at 5 V With the growth in battery-powered equipment and developments in electronic technology, supply voltages have been pushed down, and 3.3 and 3.0 V supplies are now common. In terms of power supply there are two important issues: the supply voltage required and the current that the device will then take from the supply. This supply current will be dependent on operating frequency. Also given are absolute maximum ratings, which give voltage and power dissipation levels beyond which the device must not be taken.
You may recognize that, for a battery-powered system, the required supply voltage of the 16F84A makes a three-cell alkaline battery supply a useful option. This gives a supply of around 4.5 V. Suppose you powered the system with three AA cells, each with a nominal capacity of 800 mAh. Higher frequencies need higher supply current. Running at 1.8 mA would give a battery life of 444 hours, or 18.5 days. Running at 10 mA would give 80 hours, or 3.3 days. While 15 uA consumption would lead to 53 333 hours, equivalent to 2222 days or just over six years! In this case battery self-discharge would potentially be significant. The above calculations of course only take account of the consumption of the microcontroller, and not of any other parts of the circuit.