Thursday, May 28, 2009

Oscillator Type


The PIC16F84 can be operated in four different oscillator modes. The user can program two configuration bits (FOSC1 and FOSC0) to select one of these four modes:

i. LP Low Power Crystal
ii. XT Crystal/Resonator
iii. HS High Speed Crystal/ResonatorRC Resistor/Capacitor

Sunday, April 19, 2009

PIC clock generator

Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions. Most microcontrollers will operate with a crystal and two capacitors. Some will operate with resonators or with external resistor-capacitor pair. Some microcontrollers have built-in resistor-capacitor type oscillators and they do not require any external timing components.

Friday, April 17, 2009

SFR - Special Function Robot?

The Special Function Registers are used by the CPU and Peripheral functions to control the device operation. These registers are static RAM. The special function registers can be classified into two sets, core and peripheral. Those associated with the core functions are described in this section. Those related to the operation of the peripheral features are described in the section for that specific feature

Saturday, April 11, 2009


Each General Purpose Register (GPR) is 8-bits wide and is accessed either directly or indirectly through the FSR. The GPR addresses in Bank 1 are mapped to addresses in Bank 0. As an example, addressing location 0Ch or 8Ch will access the same GPR.

Wednesday, April 8, 2009

Select Bank in PIC memory

Banking requires the use of control bits for bank selection. These control bits are located in the STATUS Register. Instructions MOVWF and MOVF can move values from the W register to any location in the register file (“F”), and vice-versa. The entire data memory can be accessed either directly using the absolute address of each register file or indirectly through the File Select Register (FSR). Indirect addressing uses the present value of the RP0 bit for access into the banked areas of data memory.

Data memory is partitioned into two banks which contain the general purpose registers and the special function registers. Bank 0 is selected by clearing the RP0 bit (STATUS<5>). Setting the RP0 bit selects Bank 1. Each Bank extends up to 7Fh (128 bytes). The first twelve locations of each Bank are reserved for the Special Function Registers. The remainder is General Purpose Registers, implemented as static RAM.

Tuesday, March 31, 2009

Data Memory

The data memory is divided into two areas. The first is the Special Function Registers (SFR) area, while the second is the General Purpose Registers (GPR) area. The SFRs control the operation of the device. Portions of data memory are banked. This is for both the SFR area and the GPR area. The GPR area is banked to allow greater than 116 bytes of general purpose RAM. The banked areas of the SFR are for the registers that control the peripheral functions.

Sunday, March 29, 2009

Program Memory

Program memory has been carried out in FLASH technology which makes it possible to program a microcontroller many times before it's installed into a device, and even after its installment if eventual changes in program or process parameters should occur. The size of program memory is 1024 locations with 14 bits width where locations zero and four are reserved for reset and interrupt vector. the first 1K x 14 (0000h-03FFh) are physically implemented (Figure 4.12). Accessing a location above the physically implemented address will cause a wraparound. For example, for locations 20h, 420h, 820h, C20h, 1020h, 1420h, 1820h, and 1C20h, the instruction will be the same. The RESET vector is at 0000h and the interrupt vector is at 0004h.

Thursday, March 26, 2009

Free PIC sample from microchip

Get free PIC sample at this link:-

Study microcontroller

This is a good tutorial on microcontroller. Link:-

Wednesday, March 25, 2009

What is PIC16F84?

PIC16F84 is a powerful (200 nanosecond instruction execution) yet easy-to-program (only 35 single word instructions) CMOS Flash/EEPROM-based 8-bit microcontroller packs Microchip’s powerful PIC® architecture into an 18-pin package. This device can be used for prototyping and production and the end application can be easily updated without removing the device from the end product via the ICSP. Easily adapted for automotive, industrial, appliances low power remote sensors, electronic locks and security applications.

Taken from

Tuesday, March 24, 2009

Memory organization

PIC16F84 has two separate memory blocks, one for data and the other for program. EEPROM memory with GPR and SFR registers in RAM memory make up the data block, while FLASH memory makes up the program block.

Sunday, March 22, 2009


PORTB is an 8-bit wide and bidirectional port. The corresponding data direction register for PORTB is TRISB. Setting a TRISB bit = 1 will make the corresponding PORTB pin an input (i.e.,put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISB bit = 0 will make the corresponding PORTB pin an output (i.e., put the contents of the output latch on the selected pin).

Wednesday, March 18, 2009


PORTA is a 5-bit wide, bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input (i.e., put the corresponding output driver in a Hi-Impedance mode). Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output (i.e., put the contents of the output latch on the selected pin).

Tuesday, March 17, 2009


Port is a group of pins on a microcontroller which can be accessed simultaneously or on which we can set the desired combination of zeros and ones. Actually, port is a register inside a microcontroller which is connected by wires to pins, where as port represents physical connection of CPU and the other circuts, devices and components.

Microcontroller uses them to monitor or control other components or devices. All port pins can be designated as input or output, according to what the devices need. Usually, microcontroller has at least two ports and each ports maybe has 8-bit register.

Monday, March 16, 2009

This diagram shows the comparison between Harvard Architecture and Von Neumann Arhitecture

Sunday, March 15, 2009

Motorola 68000

The 68000 microprocessor comprises:
- 8 data registers namely D0 - D7
- Address registers, A0 - A7
- Program counter (PC) & Status register (SR).

Data registers
Data register is used to hold data temporarily for the use in processing. Each registers can be accessed for byte operands (0-7), word operands (0-15 bits) or long-word operands (0-31 bits).
Function: Used to store information within the 68k uP itself

Address registers
Address register are not provided for storage of data for processing. Instead, they are meant to store address information. Although every registers contain 32 bits, only the lower 24 bits are used to access memory. Therefore, the address range is 224 (16M) byte.
Function: Used to store the location where data can be founded outside the processor. Ex: external memory chip. A7 usually is used to execute subroutine


Microprocessor is a complex integrated circuit or set of chips that carries out the functions for the processor of an information technology system. It contains a control unit (and clock), an arithmetic and logic unit (ALU), the necessary registers, links to main storage (memory) and to peripherals (serial and parallel input output).


Arithmetic logic unit is responsible for performing operations of adding, subtracting, moving (left or right within a register) and logic operations. $Moving data inside a register is also known as 'shifting'. PIC16F84 contains an 8-bit arithmetic logic unit and 8-bit work registers.

In instructions with two operands, ordinarily one operand is in work register (W register), and the other is one of the registers or a constant. By operand we mean the contents on which some operation is being done, and a register is any one of the GPR or SFR registers. GPR is an abbreviation for 'General Purposes Registers', and SFR for 'Special Function Registers'. In instructions with one operand, an operand is either W register or one of the registers.

As an addition in doing operations in arithmetic and logic, ALU controls status bits (bits found in STATUS register). Execution of some instructions affects status bits, which depends on the result itself. Depending on which instruction is being executed, ALU can affect values of Carry (C), Digit Carry (DC), and Zero (Z) bits in STATUS register.

Saturday, March 14, 2009

CPU in Microcontroller

Central processing unit (CPU) is the brain of a microcontroller. CPU is responsible for finding and fetching the right instruction which needs to be executed, for decoding that instruction, and finally for its execution.

Central processing unit connects all parts of the microcontroller in one systems. CPU most important function is to decode program instructions. When programmer writes a program, instructions have a clear form like MOVWF PORTB. However, in order for a microcontroller to understand that, this 'letter' form of an instruction must be translated into a series of zeros and ones which is called an 'opcode'. This translation from a letter to binary form is done by translators such as assembler translator or also known as an assembler.

Instruction fetched from program memory must be decoded by a central processing unit (CPU). We can then select from the table of all the instructions a set of actions which execute a assigned task defined by instruction. As instructions may within themselves contain assignments which require different transfers of data from one memory into another, from memory onto ports, or some other calculations, CPU must be connected with all parts of the microcontroller. This is made possible through a data bus and an address bus.

Block diagram for Mc

This is block diagram for microcontroller

Harvard Architecture Vs Von Neumann Architecture

Generally there are two types of architecture for personal computers or desktop computers. Most desktop computers use von Neumann architecture, where programs and data share a single memory area that is accessed over a common bus. This scheme works well for general use computers but may not be of particular advantage for microcontrollers. That's why the PIC microcontroller uses Harvard architecture. This architecture design uses separate memory areas and buses for data and programs.

For Harvard architecture the instruction bus is allowed to be a different width than the data bus. So, an instruction can be fetched in a single clock cycle because the instruction bus can be custom tailored. The last instruction can be executed by cpu while the next one is being fetched, all while data memory is simultaneously being accessed.

Thursday, March 12, 2009

Block Diagram Mp

This is block diagram for Microprocessor

Microcontroller Vs Microprocessor

Microprocessor and microcontroller are two pupolar terms in world of computer. However,microprocessor and microcontroller has different functions and features.

Microprocessors generally require external components or circuits to implement program memory, RAM memory and Input/Output. Intel's 8085, 80386 and Pentium are examples of microprocessors. Microcontrollers incorporate program memory, RAM memory and input/output port into one chip. Microchip's PIC series and Atmel's AVR series are examples of microcontrollers.

One of the main differences is that microcontrollers are usually designed to perform a small set of specific functions, for example as in the case of a Automatic Braking System which performs a small set of input processing functions, whereas microprocessors tend to be designed to perform a wider set of general purpose functions. For example, microcontrollers are widely used in modern cars where they will each perform a dedicated task, i.e. a microcontroller to regulate the brakes on all four wheels, or a microcontroller to regulate the car air conditioning, or a microcontroller for automatic gate systems.

These microcontrollers will perform few other tasks (if any) other than those specified. Compare to a microprocessor in a PC which performs a wide range of tasks related to the general requirements of a PC such as performing the necessary calculations for a very wide set of software applications, performing Input/Output for the main subsystems, peripheral control and etc.

Wednesday, March 11, 2009

PIC - Introduction

PIC16F877 is one of the PIC series that has been developed by Microchip Technology. PIC stands for Programmable Interface Controller. PIC16F877 also one of the most popular microcontroller that has been used widely. PIC16F877 features 256 bytes of EEPROM data memory, self programming, an ICD, 8 channels of 10-bit Analog to Digital (A/D) converter, 2 additional timers, 2 capture/compare/PWM functions, the synchronous serial port that can be configured as either 3-wire Serial Peripheral Interface (SPI) or the 2 wire InterIntegrated Circuit (I²C) bus and a Universal Asynchronous Receiver Transmitter (USART). All of these features make it ideal for more advanced level Analog to Digital applications in automotive, industrial, appliances and consumer applications such as digital thermometer, automatic gate, calculator and etc.