Home »
Embedded Systems
Oscillator Frequency in Microcontrollers
Microcontrollers | Oscillator Frequency: In this tutorial, we will learn about Oscillator Frequency, why are they required, and why they are an important aspect of embedded systems development.
By Sudarshan Paul Last updated : May 13, 2023
What is oscillator frequency in microcontrollers?
The digital computer systems must contain an oscillator circuit for its functioning. The oscillator circuit is often regarded as the 'heartbeat' of an embedded system. Any malfunctioning of the oscillator will directly have an impact in the normal functioning of the system. The system depends upon the oscillator for all time-related calculations.
Relation between oscillator frequency and machine-cycle period
The speed at which microcontroller processes the applications depends upon the oscillator frequency. The frequency forms the basis for comparing two different microcontrollers. The 8051 microcontroller runs with a minimum 12 oscillator cycles in order to execute a machine function. The performance of an 8051 microcontroller can be improved simply by increasing the clock frequency. The performance can also be improved by upgrading the internal components so that fewer oscillator cycles are required in order to complete a machine instruction. The modern desktop PC operate with around 1000 MIPS (Millions of instructions per second) or more. Among that majority of the performance is consumed by the Operating System. Whereas an embedded operating system will consume at most 1% of the full operating frequency, thus leaving a greater percentage of performance to deal with complex embedded operations.
Why a low oscillator frequency microcontroller is preferred?
The following are the reasons to prefer a low oscillator frequency microcontroller:
- Many people might think that selecting a microcontroller of higher frequency delivers maximum performance. This can be a mistake, because of the following reasons -:
- Using applications which don't require the level of performance that modern 8051 device offers.
- In modern 8051s, the oscillator frequency and power supply current vary linearly with each other. As a result, by choosing a device with the low frequency the power requirements can be brought down.
- The electromagnetic interference generated by a circuit can be reduced by using a device with low clock frequency.
- While accessing low-speed peripherals, the cost of peripheral components can be reduced if the chip is operating at low frequency. Also, the design and programming become simplified.
Concept of timers and interrupts for oscillator frequency
Timers
Members of 8051 families consisting of at least two timers, namely Timer ) and Timer 1. Timers are very important in the development of embedded systems. Timers are properly configured so that they can be periodically incremented after completion of a specific number of cycles. In 8051 timers, the timers are incremented for every 12 oscillator cycles. If we have a 12MHz oscillator, then the timer will be incremented 1 million times per second.
Timers can be used for,
- Measuring intervals of time
- Generating hardware delays
- Generate 'time out' facilities
Interrupts
An interrupt is a hardware mechanism through which the process is notified about an event that has taken place. Interrupts help in assisting multiple tasks that are to be performed at a time using a single processor.
In the above figure, we can see that when function 1 is executed an interrupt is raised that is referred to as ISR1 (interrupt service routine). Function 1 resumes its operation after execution of ISR1 is complete.
Now the question comes what is an interrupt service routine?
In terms of C programming, interrupt service routine is a function that is 'called by the microcontroller', as a result of a particular hardware event.