Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Choosing a PIC microcontroller

Choosing a right PIC Microcontroller is always crucial for any project related to microcontrollers.
Choosing a PIC microcontroller
Introduction to PIC microcontrollers:- PIC microcontrollers are popular processors developed by Microchip Technology with built-in RAM, memory, internal bus, and peripherals that can be used for many applications. PIC originally stood for “Programmable Intelligent Computer” but is now generally regarded as a “Peripheral Interface Controller”.

Types of PIC :- PIC microcontrollers are of two major categories: 8-bit microcontrollers and 16-bit microcontrollers. Each category is further subdivided into product families as shown in the following table:
8-bit MCU Product Family
PIC10,PIC12,PIC14,PIC16,PIC18

16-bit MCU Product Family
PIC24F,PIC24H,dsPIC30,dsPIC33

The microcontrollers in the PIC10 through PIC14 families are considered low-end microcontrollers.
PIC microcontrollers in the PIC16 and PIC18 families are considered mid-level microcontrollers
while 16-bit PICs are considered high-end microcontrollers. :smile: :smile:

Which one top choose :-
Each PIC has unique features and subtle differences. The correct choice for your project depends
on many factors:
 Does the project require analog input or output?
 Does the project require digital input or output?
 How many I/O pins are required?
 Does the project require precise timing?
 How much memory does the project require?
 Is serial I/O required? Etc.

PICs also come in several types of packages:
 Plastic Dual Inline Package (PDIP)
 Small-Outline Transistor (SOT)
 Dual Flat No-lead (DFN)
 Mini Small Outline Package (MSOP)
 Thin Quad Flat Pack (TQFP)
 Plastic Leaded Chip Carrier (PLCC)
 CERamic QUADpack (CERQUAD)

Integrated Development Environment
In order to develop your software and organize your files you will have to use an integrated
development environment. The number one IDE used with PIC microcontrollers is MPLab IDE by Microchip Technology. MPLab IDE
You can also download the MPLab IDE User’s Guide, Quick Chart, and Quick Start Guide. After you have downloaded the latest version of MPLab IDE install the software on your local drive.

Programming Language :-
PIC microcontrollers can be programmed in Assembly, C or a combination of the two. Other high-level
programming languages can be used but embedded systems software is primarily written in C. The following three examples demonstrate the programming styles.
Example 1 – Assembly
Code:
MAIN
clrf PORTB ;Clear PORTB output latches
bsf STATUS,RP0 ;Switch to bank 1
movlw b'11110000' ;Load value to make lower 4 bits outputs
movwf TRISB ;Move value to TRISB
bcf STATUS,RP0 ;Switch to bank 0
LOOP
bsf PORTB,0 ;Turn on LED on RB0
call DELAY ;Call delay routine
bcf PORTB,0 ;Turn off LED on RB0
call DELAY ;Call delay routine
goto LOOP ;Repeat main loop
DELAY
decfsz COUNTERL ;Decrement COUNTERL
goto DELAY ;If not zero, keep decrementing COUNTERL
decfsz COUNTERH ;Decrement COUNTERH
goto DELAY ;If not zero, decrement COUNTERL again
return
END

Example 2 – Assembly and C
Code:
main()
{
short first_pass = TRUE;
//----- Set up port direction reg's -----
#asm
movlw 0 // Set port b to outputs
tris port_b
clrf port_b
movlw 0xff // Set port a to inputs
tris port_a
#endasm
//----- Wait for powerup, Initilize LCD -----
delay_ms(200);
init_lcd();
//----- Write a startup message -----
msg_1();
//----- Write status message -----
msg_2();
…

Code:
[B]Example 3 – C [/B]
void main() {
U8 i = 0; // General purpose loop var.
U16 num ; // General purpose number var.
U8 row = 0; // Current display row.
U16 blinkc = 0; // LED blinker counter.
U16 blink_onoff = 1; // LED state.
U8 bcd_h,bcd_m,bcd_s; // BCD numbers.
init_ports();
init();
enable_interrupts();
ROW_RESET;
/////////////////////////////
for (;;) { // infinite loop
// FLASH LED @ RA3
if (++blinkc>500) { // time to change state ?
blinkc=0;
…
I suggest writing your code completely in C because it is much faster and easier than writing your
code in Assembly or a combination of languages. :wink:

Building Software(Code which to be dumped in microcontroller)
main.c
Code:
//LED example program written for
//PIC programming tutorial.
//standard include files
#include <stdlib.h>
#include <pic.h>
#include “delay.h”
//main function
void main()
{
PORTA = 0x00; //set RA0-RA5 low
TRISA = 0x00; //set PORTA to output
//superloop
while(1)
{
PORTA = !PORTA;
DelayMs(250);
}
}

The “Burning” Process
Once you have you software written you can compile your code to check for syntactical errors.
The first important step in the “Burning” processing is building your project. Before building your
project make sure your configuration bits are set appropriately by selecting Configure 
Configuration Bits. Then select Project  Build All or hit Ctrl + F10 to build your project.
The output window will print the results of each step in the build process. You will probably
receive some warning or advisory messages. If the build process was successful locate Hexadecimal file,Copy this HEX file and take it to the computer connected to your available programmer.


Read this document for more information :-https://ee.sharif.edu/~sakhtar3/books/PIC%20Microcontroller%20Application%20Guide.pdf

Comments

The PIC series now has 32-bit controllers - the PIC32 series. These are truly high-end controllers compared to the other PIC controllers. At the same time, these are not too difficult to use, and are not too expensive either.
 

Part and Inventory Search

Blog entry information

Author
vicky001.iith
Read time
4 min read
Views
1,869
Comments
3
Last update

More entries in Uncategorized

More entries from vicky001.iith

Share this entry

Back
Top