Chapter - 1 Introduction To Microcontroller
Chapter - 1 Introduction To Microcontroller
The history of PIC (Peripheral Interface Controller) microcontrollers traces back to the
development efforts of General Instrument's Microelectronics Division in the 1970s. Here
is a brief overview of the history of PIC microcontrollers:
Throughout their history, PIC microcontrollers have become widely adopted in various
applications due to their reliability, cost-effectiveness, and a broad range of available
devices to meet different requirements. The microcontrollers have played a crucial role
in embedded systems, industrial automation, consumer electronics, and many other
fields.
1. Architecture:
o PIC18 microcontrollers use a modified Harvard architecture with an 8-bit
data path and a 16-bit instruction word.
o Features a RISC (Reduced Instruction Set Computing) architecture for
efficient and fast execution of instructions.
2. Memory:
o Flash Program Memory: PIC18 devices have flash memory for program
storage. The size of the flash memory varies across different devices within
the family.
o RAM (Random Access Memory): Includes on-chip RAM for data storage
during program execution.
3. Peripheral Integration:
o PIC18 microcontrollers offer a wide range of integrated peripherals,
making them suitable for diverse applications.
o Common peripherals include GPIO (General Purpose Input/Output),
timers, UART (Universal Asynchronous Receiver-Transmitter), SPI (Serial
Peripheral Interface), I2C (Inter-Integrated Circuit), and PWM (Pulse
Width Modulation).
4. Analog Features:
o Integrated Analog-to-Digital Converters (ADCs) for converting analog
signals to digital values.
o Some members of the PIC18 family may also include Digital-to-Analog
Converters (DACs) for generating analog output.
5. Communication Interfaces:
o UART, SPI, and I2C communication interfaces facilitate connectivity with
other devices.
o USB (Universal Serial Bus) support is available in certain PIC18
microcontrollers.
6. Timers and PWM:
o Multiple timers/counters for generating accurate time delays and
managing periodic events.
o Pulse Width Modulation (PWM) modules for controlling motor speed, LED
brightness, and other applications.
7. Interrupt System:
o An interrupt system for handling external events and prioritizing interrupt
requests.
8. Low-Power Modes:
o Power-saving features, including low-power modes and sleep modes, to
optimize energy consumption in battery-powered applications.
9. Security Features:
o Some PIC18 devices offer security features such as code protection and
data EEPROM/Flash write protection to safeguard intellectual property.
10. Development Tools:
o A variety of development tools, including integrated development
environments (IDEs) like MPLAB X, compilers, and debugging tools,
support PIC18 microcontroller development.
11. Variety of Packages:
o PIC18 microcontrollers come in various packages, offering flexibility in
terms of board design and space constraints.
Applications:
• Industrial automation
• Consumer electronics
• Medical devices
• Automotive systems
• Home appliances
• Lighting control
• Embedded control systems
Clock Frequency
The clock frequency of a PIC18 microcontroller is a critical parameter that influences the
speed at which the microcontroller executes instructions and performs operations. The
clock frequency is determined by an external oscillator or a crystal connected to the
microcontroller.
Here are some key points regarding the clock frequency of PIC18 microcontrollers:
1. Oscillator Types:
o PIC18 microcontrollers can use various types of oscillators, including
internal oscillators, external crystals, resonators, or external clock sources.
o The choice of oscillator depends on the specific requirements of the
application, such as accuracy, stability, and power consumption.
2. Internal Oscillator:
o Some PIC18 microcontrollers have an internal oscillator, which eliminates
the need for an external crystal or resonator.
o The internal oscillator frequency is usually specified in the
microcontroller's datasheet.
3. External Crystal or Resonator:
o Many PIC18 microcontrollers are designed to work with an external crystal
or resonator for improved accuracy and stability.
o The clock frequency is determined by the external oscillator's frequency.
4. Clock Frequency Configuration:
o The clock frequency can be configured using the configuration bits in the
microcontroller. This is typically done in the configuration word or
configuration registers.
o The configuration bits specify the oscillator source, frequency range, and
other settings.
5. Frequency Ranges:
o PIC18 microcontrollers often support different frequency ranges, such as
low-frequency ranges (LF), medium-frequency ranges (MF), and high-
frequency ranges (HF).
o The specific frequency range may vary based on the microcontroller model.
6. Crystal Oscillator Modes:
o PIC18 microcontrollers may support different crystal oscillator modes,
such as HS (High-Speed Crystal), XT (Crystal), and LP (Low-Power Crystal).
o The oscillator mode influences the stability and accuracy of the clock
source.
7. Maximum Frequency:
o The maximum clock frequency that a PIC18 microcontroller can support is
specified in its datasheet.
o It is important to ensure that the chosen clock frequency does not exceed
the microcontroller's maximum rated frequency.
8. Power Consumption:
o The clock frequency can impact the power consumption of the
microcontroller. Higher clock frequencies generally lead to higher power
consumption.
Machine Cycle:
A machine cycle is the basic unit of time during which the PIC 18 microcontroller
performs a single operation. It consists of a sequence of states required to execute one
instruction. The machine cycle is further divided into several clock cycles, and the number
of clock cycles in a machine cycle depends on the oscillator frequency and the specific
instruction being executed.
1. Fetch: During this state, the microcontroller retrieves the instruction from
memory.
2. Decode: The microcontroller decodes the fetched instruction to determine the
operation to be performed.
3. Execute: The actual execution of the operation specified by the instruction takes
place in this state.
4. Write: If necessary, the results of the operation are written back to memory or
registers.
Instruction Cycle:
The instruction cycle, also known as an "execution cycle" or "execution time," is the time
required to complete the execution of a single instruction. It is measured in terms of the
number of machine cycles needed to execute the instruction. The instruction cycle is
determined by the specific instruction being executed and the oscillator frequency.
The instruction cycle is a crucial parameter when calculating the execution time of a
program or when determining the maximum achievable throughput of the
microcontroller.
Example:
Keep in mind that the specific details, such as the number of machine cycles per
instruction, can vary between different PIC 18 microcontroller models. Therefore, it's
essential to refer to the specific datasheet and reference manual of the PIC 18
microcontroller you are working with for accurate and detailed information on machine
cycles and instruction cycles.