Microcontrollers are the system-on-chip devices, where emphasis is on reducing the chip count in the system as a whole. The number of features has been integrated inside it, and is described below:
They have an internal clocking circuit that allows easy interfacing of an external crystal with few capacitors or with an external clock input. They may also have an internal ring oscillator allowing it to run from the internally generated clock input. These clock inputs are used to synchronize the internal operations and to help in sequencing the execution of instructions as an an instruction cycle require a specific number of states or clock inputs. Internally, 8051 generates a two phase clock requiring the microcontroller six ‘T’ states or 12 clock cycles for each instruction cycle.
All Controllers provide a number of I/O lines or I/O ports. These i/o lines may have more than one function, in which case, it will have a mechanism of selecting the lines for a particular function. The bus may require some control information so that it may be used for read or the write operation. Figure 3.1 shows the general layout of the i/o line. To activate the write operation to a pin we need to activate the upper buffer (marked 1), to do so, we write a ‘1’ to the upper D latch. With this setting whatever is the output of the lower D latch will be outputted to the pin. To read a pin, we activate the lower buffer (marked 2) and deactivate upper buffer (marked 1). This make the upper buffer become turn OFF, and lower buffer ON. Thus the status of the pin is read through the lower buffer.
8051 provide four ports (P0 – P3) to act as bidirectional i/o ports. All ports except port P1 also provide alternate function, this helps in reducing the number of pins on the chip.
Interrupts are a good mechanism of servicing of the requests by the interfaced external devices. When any of the ecternal devices need the attention of the controller, they send a signal on an interrupt pin of the controller. On receiving a signal on this interrupt pin, the microcontroller comes out of the normal execution sequence and jumps to another location to service the request of the interrupting device. On serving the device request, the controller takes control of the previously executing program sequence. This interrupt may come in any of the following way:
For this, microcontrollers provide an interrupt line through which the controller can be requested for its attention. An example of this system may be the power unit failure, the monitoring unit of the power supply will send a signal to the controller indicating that the power is now on back up supply unit and will last for few minutes. On receiving such signal the controller may save the important data before shutting down.
It may be required to intimate the controller after some of the slow routines get completed. These slow routines are the inbuilt routines within the controllers and the examples of such routines are those using the functionalities of timers, counters, serial ports etc.
On receiving the exceptions, the microcontroller enters into the remedial cycle for action on such exceptions. These exceptions occur whenever any unexpected operations such as divide by zero occur.
Timers in microcontroller find a lot of applications. Some of these being:
Most microcontrollers contain a number of hardware modules. In the past many of these were designed as separate chips in a conventional microprocessor system which required their interfaces for connecting to the processor. Rather than using a separate bus with the microcontroller, many peripherals are integrated directly onto to the chip itself. This allows greater functionality in a single chip and saves the space. Typical peripheral devices are: