Abbreviated as è µC, uC or MCU
A microcontroller is defined as a small computer on a single integrated circuit composed of a memory , programmable i/o peripherals and processor core.
Microcontrollers are designed for small and specific applications like to control a particular system.
Microcontroller programs must fit in the available on-chip program memory. Compilers and assembly language are used to turn high-level language programs into a compact machine code for storage in the microcontroller’s memory.
The microcontroller acts as the brain. From the algorithms set to the chip, it will react accordingly to the functions available for execution. The buttons pressed to execute instant messages out, that will activate alarm as well as SMS, all this will be assigned to the chip and controlled by it.
Many companies manufacture microcontroller units such as Microchip, Motorola, Intel and others.
Pic18f4520 is the Microcontroller made by Microchip will be used in most of the projects in this website.
PIC is a family of Harvard architecture microcontrollers made by Microchip Technology.
PIC’s are RISC (Reduced Instruction Set Computer). That means less consumption of silicon area as well as less consumption of power.
Executes one instruction in one internal clock cycle.
The PIC18FXXXX microcontrollers are “Harvard Architecture” microprocessors, meaning that program memory and data memory are in separate spaces. This allows faster execution as the program and data buses are separate and dedicated, so one bus does not have to be used for both memory types. The program memory space is addressed by a 12-bit Program Counter, allowing a 2 Mb program memory space. The program memory type is flash, therefore it can be programmed multiple times using programmer/debugger (e.g. ICD2, ICD3).
PIC18F4520 from Microchip is an 8-bit microcontroller with five ports :
v PortA 8 I/O pins,
v PortB 8 I/O pins,
v PortC 8 I/O pins,
v PortD 8 I/O pins and
v PortE 6 I/O pins).
v Pin6 and pin7 of PortC are dedicated for the serial communication of the USART (Universal synchronous asynchronous receiver transmitter) of the PIC18F4520.
It has Master Synchronous Serial port (MSSP) which supports SPI and I2C Master and Slave Mode. It also has up to 5 PWM outputs and Up to 2 Capture / Compare.
In addition, PIC18F4520 comes with internal timers named Watchdog Timer (to reset the PIC) and Power-up Timer.
It also has four other timer modules where timer0 and timer1 work with 8 bit or 16 bit, timer 3 works with 8 bit and timer 4 works with 16 bit only. These timers can also be used as clock source for the PWM module.
Definition of Timer: A Timer is just a register whose value keeps on increasing or decreasing by a constant rate without the help of CPU. The CPU can read or write this register anytime. It read it to find out how much has elapsed. While using timers the CPU clock can be divided to obtain a smaller frequency by using prescaler.
Interrupts: In PIC18F4520, an interrupt is a hardware event that stops execution of the mainline software to respond to the hardware event using software and then returns execution back to the mainline where the interrupt took place. Interrupt reduces the complexity of application code.
Sources of interrupt in PIC18F4520 are as follows:
1) INT pin interrupt from external source
2) PORTB change interrupt( RB0:RB4)
3) Timer overflow interrupt
4) USART interrupt
5) A/D conversion interrupt
6) LCD interrupt
7) And others