Hi Fellas! I am back to give you have a daily dose of valuable information so you keep coming back for what we have to offer. Today, I will discuss the details on the Introduction to PIC16F628a. It is defined as a self-contained 18-pin PIC Microcontroller that comes with memory, processor, peripherals and mainly used for embedded systems and applications.
Microcontrollers always remain a top priority for experts where automation is the main concern. Before the invention of microcontrollers, microprocessors were widely used for carrying out different functions related to industrial automation and processing applications. Both of them work identical in one way or the other, however, there are some exceptions i.e. microprocessors don't come with ROM, RAM, and other peripherals, we need to add them externally to make them function like a microcontroller, however, microcontroller comes with all peripherals on the single chip, we don't need to add them externally; that is what makes it compact as compared to a microprocessor that is bulky.
I this tutorial, I'll discuss each and everything related to PIC16F628a, its main features, pinout, working, and applications. Let's jump right in and nail down everything you need to know.
Introduction to PIC16F628a
PIC16F628a is an 18-pin tiny chip that contains processor, memory, I/O pins, other peripherals and mainly used for the embedded system, and in the applications that have a remote or direct connection with the automation.
It is a low cost, high performance, CMOS Flash-based 8-bit microcontroller and is equally compatible with PIC16F628, PIC16C5X, PIC16C62XA and PIC12CXXX devices.
The PIC16F628a comes with 128 bytes of EEPROM data memory, 4MHz internal oscillator, two 8-bit and one 16-bit timer, USART, PWM, two comparators and programmable low voltage reference that make it suitable for appliances, automotive, industrial and consumer applications.
The PIC processor is based on advanced RISC architecture and comes with 35 instruction set that is simple to use and easy to configure.
Like some controllers in the PIC community, the PIC16F628a features operating range around 2 to 5.5 V where the temperature range is -40 to 125 °C.
Programmable memory size is 3.5 KB and SRAM is 224 bytes.
This PIC model is capable of storing 2048 words of program memory so maximum program length can't exceed from 2048 instructions where each word defines a single instruction.
Four clock cycles are needed to execute each instruction except jump and conditional instructions that may require 8 clock cycles.
Following figure shows the pinout of PIC16F628a.
Looking at the pinout of the controller above, you can clearly anticipate most of the pins on the left side can be used for multiple purposes, however, specifying any pin for particular function rules out the use of that pin for another purpose.
There are two ports in this model known as Port A and Port B.
All these pins are bidirectional I/O pins except Pin #14& Pin #5 that are supply voltage and ground pins respectively.
Pin # 4 can be used in three ways.e. MCLR (Master Clear) that requires a constant supply of 5V and must not exceed Vdd. When configured as MCLR, this pin behaves as an active low Reset to the device. It is also used as an input port and programming voltage input.
Pin # 15 & 16 are known as OSC2 (Oscillator 2) and OSC1 (Oscillator 1), where we can attach an external oscillator of around 20MHz. The Pin #16 is an input for the crystal oscillator and Pin #15 acts like an output for the oscillator.
Both Pin # 2 and Pin #3 are the analog comparator pins where Pin #3 is also used as a clock input for Timer0.
Pin #6 is a bidirectional I/O pin that can be used for an external interrupt.
Pin # 9 is used for capture, compare and PWM and can be software programmed.
Pin#10 is a low voltage programming input pin and can also be used for interrupt-on-pin change. It is important to note that when low voltage programming is configured, then both "weak pull-up resistors and interrupt-on-pin change" are disabled.
If you are new to microcontrollers and feel difficulty in finding the right approach to get the hands-on experience with controller then you can have a look at Introduction to Microcontrollers where I have laid out everything you need to know and with little effort you can become pretty nifty about controller and streamline real-time projects as per your needs and requirements.
The memory layout is a little bit different where each memory location is considered as a register that can be accessed by its address.
It is important to note that, not all register are available all the time, and memory is laid out in four banks that come with 128 registers and only one back can be accessed at a given time.
The first 32 registers in each bank are known as special purpose registers that can be used to control the processor and I/O pins. The last 16 registers available in each bank are shared across all banks whose values can be accessed any time without depending on the specific bank being used.
There exists a single working register known as "W" that is mainly used to store the modified values of the different function being used in the controller.
The memory capacity of this model is little less than other controllers available in the market, however, you can compile a function that requires minimum instructions and processing speed. If you intend to work with high processing speed and more memory, then you need to consider working with PIC16F877a.
This model of PIC controller is very useful for embedded projects and comes with some valuable features that put this advice ahead of many controllers in the PIC community.
Special Microcontroller Features
Low voltage programming that programs the chip using the operating voltage of the device
Low-speed Clock mode
Programmable Brown-Out Reset (BOR)
Watchdog Timer with an independent Oscillator for reliable operation
Selectable Oscillator Options
Programmable code protection
Multiplexed Master Clear/Input-pin
Industrial temperature range
I/O and Packages
15 I/O pins with individual direction control
18-pin DIP & SMD Package
High-Performance RISC CPU
Only 35 single word instructions to learn
All instructions are a single cycle (1µs) except for program branches
Operate at 20MHz with an external oscillator
4MHz internal oscillator that gives a clock at a certain frequency using constant voltage. It can be made to work at 48 KHz for power saving and debugging purpose
MPLAB C18 Compiler is the standard compiler used for PIC microcontrollers. You can get this compiler online from the Microchip Official Site.
Third party applications are also available for compiling the program where MikroC Pro For PIC stays ahead from other compilers available in the market.
You must check this list of Top 3 PIC C Compilers where you can pick any compiler based on your needs and requirements.
The code is written in PIC Compiler that compiles the code and generates a hex file that is uploaded on the PIC Microcontroller.
Mainly used in embedded system
Industrial automation and processing applications
Home automation and security systems
Data Processing Units
That's all for today, I hope I have provided you everything you need to know related to this controller. If you are unsure or have any question, you can ask me in the comment section below. I'd love to help you in any way I can. Feel free to keep us updated with your valuable suggestion, they help us provide you a quality work. Thanks for reading the article.
I am Syed Zain Nasir, the founder of The Engineering Projects (TEP). I am a
programmer since 2009 before that I just search things, make small projects and now I am sharing my
knowledge through this platform. I also work as a freelancer and did many projects related to
programming and electrical circuitry. My Google Profile+Follow