Exploring the World of PIC Microcontrollers: An Architectural Overview

A Peripheral Interface Microcontroller (PIC), developed by General Instruments Microcontrollers in 1993, operates under software control and is programmed to execute various tasks, regulating production lines. PIC microcontrollers find application in diverse fields including smartphones, audio accessories, and cutting-edge medical devices.

PIC Microcontrollers

Various PIC microcontrollers are available in the market, spanning from the PIC16F84 to the PIC16C84, offering affordable flash capabilities. Microchip has recently expanded its lineup to include flash chips like the 16F628, 16F877, and 18F452. While the 16F877 comes at twice the cost of the older 16F84, it boasts significantly larger code capacity, increased RAM, an abundance of I/O pins, as well as additional features such as UART, A/D converter, among others.

PIC Microcontrollers Architecture

The PIC microcontroller operates on RISC architecture, featuring a memory structure adhering to the Harvard design, where distinct memories are allocated for program and data, each with their own dedicated buses.

PIC microcontroller architecture

1. Memory Structure

The PIC architecture comprises two types of memory: Program memory and Data memory.

Program Memory: This memory space is structured as 4K*14 and is designated for storing either 13-bit instructions or program code. Access to the program memory data is facilitated through the program counter register, which retains the address of the program memory. The memory space at address 0000H serves as the reset memory space, while 0004H is allocated for interrupt handling.

Data Memory: The data memory is comprised of 368 bytes of RAM and 256 bytes of EEPROM. The RAM portion comprises multiple banks, each containing general-purpose registers and special function registers.

The special function registers encompass control registers responsible for managing various functionalities of the chip’s resources such as Timers, Analog to Digital Converters, Serial ports, I/O ports, and more. For instance, the TRISA register enables manipulation of its bits to modify the input or output functions of port A.

Meanwhile, the general-purpose registers are designated for storing temporary data and processing outcomes. These registers are all 8-bit in size.

Working Register: It comprises a memory space where operands for each instruction are stored, along with the results of each execution.

Status Register: The status register bits indicate the state of the ALU (Arithmetic Logic Unit) following each instruction execution. Additionally, they serve to choose one of the four RAM banks.

File Selection Register: It functions as a reference to any other general-purpose register, containing a register file address, and is employed in indirect addressing.

The program counter register, a 13-bit register, serves as another general-purpose register. Its 5 upper bits function as PCLATH (Program Counter Latch), operating independently like any other register, while the lower 8 bits act as the program counter bits. This program counter functions as a pointer directing to the instructions stored in the program memory.

EEPROM: The EEPROM of the microcontroller comprises 256 bytes of memory space. Functioning similarly to ROM in terms of permanence, it allows for erasure and alteration of its contents during microcontroller operation. Accessing and modifying the EEPROM’s contents is facilitated through special function registers such as EECON1 and EECON.

2. I/O Ports

The PIC16 series comprises five ports, namely Port A, Port B, Port C, Port D, and Port E.

Port A: This port is 16 bits wide and can function either as an input or output port, depending on the configuration set in the TRISA register.

Port B: This port operates at 8 bits and functions as both an input and output port. When configured for input, four of its bits are capable of being altered by interrupt signals.

Port C: It functions as an 8-bit port where its operation, whether input or output, depends on the status of the TRISC register.

Port D: This port operates as an 8-bit interface, serving not only as an input/output port but also functioning as a subordinate port linked to the microprocessor bus.

Port E: This 3-bit port also fulfills the role of providing control signals to the A/D converter in addition to its primary function.

3. Timers

PIC microcontrollers include three timers: Timer 0 and Timer 2 are 8-bit timers, while Timer 1 is a 16-bit timer that can also function as a counter.

4. A/D Converter

The PIC Microcontroller features an 8-channel, 10-bit Analog to Digital Converter (ADC). The functionality of the ADC is managed through specific special function registers, namely ADCON0 and ADCON1. ADRESL holds the lower 8 bits of the conversion result, while ADRESH stores the upper bits. A 5V analog reference voltage is necessary for proper operation.

5. Oscillators

Timing generation in PIC microcontrollers relies on oscillators. These oscillators, such as crystals or RC circuits, serve as external sources. When utilizing crystal oscillators, a crystal is linked between two designated pins, with the capacitor value on each pin dictating the oscillator’s mode of operation. These modes include low-power, crystal, and high-speed modes. Conversely, RC oscillators’ clock frequency is determined by the resistor and capacitor values, spanning from 30 kHz to 4 MHz.

6. CCP module:

A CCP module operates within three distinct modes:

Capture Mode: This mode records the arrival time of a signal, essentially capturing the Timer1 value when the CCP pin transitions to a high state.

Compare Mode: It serves as an analog comparator, producing an output once the timer1 value meets a specific reference threshold.

PWM Mode: It offers pulse-width modulated output featuring a 10-bit resolution and customizable duty cycle programming.

Additional special peripherals comprise a Watchdog timer, which initiates a reset of the microcontroller upon software malfunction, and a Brownout reset, which triggers a reset in response to power fluctuations, among others. To enhance comprehension of this PIC microcontroller, we provide a practical project that leverages this controller for its functionality.

Street Light that Glows on Detecting Vehicle Movement

The objective of this project is to create a system for controlling LED street lights, which is capable of detecting vehicle movement on the highway. It switches on a set of street lights in advance of the vehicle’s path, while simultaneously turning off lights behind it to conserve energy. The programming of a PIC microcontroller for this project is implemented using either embedded C or assembly language.

Street Light that Glows on Detecting Vehicle Movement

The power supply circuit functions to provide power to the entire circuit through a series of steps including stepping down, rectifying, filtering, and regulating the AC mains supply. During periods of no vehicle activity on the highway, all lights remain off to conserve power. Positioned on either side of the road, IR sensors detect vehicle movement and relay commands to the microcontroller, which controls the activation and deactivation of LEDs. When a vehicle approaches, a block of LEDs illuminates, adjusting its intensity or switching off as the vehicle passes by.

Projects utilizing PIC microcontrollers find application across various domains such as peripherals for video games, audio accessories, and more. Should assistance be required for any projects, feel free to reach out by commenting in the designated section.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.