Features of Microcontrollers :
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:
Request on a particular line/pin:
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.
Interrupt on completing of routine:
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:
- To provide interrupt signal to the microcontroller
- To provide pulse width modulation (PWM): this consists of repeating the signal with a pulse of a given duty cycle. This pulse is active only for a small % of the duty cycle which can be from 0 to 100% of the duty cycle. This type of cycle is used for the speed control of DC motors.
- To provide time delay for some operations: The counters may be set to count to a predefined number before interrupting the microcontroller. This interval is calculated by using the following formula. Interval = (Max_Count – Reload) / Clock_freq where Max_count is the overflow value of counter which will be 256 for 8-bit counter and 65536 for the 16-bit counter, reload value is the time delay required/time of one clock cycle of the controller. For example to get a time delay of 5 ms using 8051 running on 11.0592MHz, we proceed as: time of 1 clock pulse in 8051=1/11.0592M=1.085 us, so, reload=5ms / 1.085 us =4508 clock. Therefore interval=65536-4608 = 60928 = 0xEE00. So the counter will be loaded with this hex number (i.e. EE00H).
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:
- Serial I/O module: This allows the serial transmission and receiving of data to / from the peripherals
- Analogue to Digital Converter module
- Controller Area Network (CAN) interface
- Ethernet interface module (LAN)
- Universal Asynchronous Receiver/Transmitter (UART) module.
- Pulse Width Modulation (PWM)
- EEPROM data memory
- USB interface
- Interface to LCD
- Interface for Motor Control