Introduction to MPLAB IDE
Upcoming SlideShare
Loading in...5
×
 

Introduction to MPLAB IDE

on

  • 4,488 views

A starter guide how to use Microchip MPLAB IDE for PIC microcontrollers and related tools like MPLAB C18, C30 and C32 compilers, and how to MPLAB features to get connected and integrated with ...

A starter guide how to use Microchip MPLAB IDE for PIC microcontrollers and related tools like MPLAB C18, C30 and C32 compilers, and how to MPLAB features to get connected and integrated with programmer/debugger devices and development kits from Microchip.

Statistics

Views

Total Views
4,488
Views on SlideShare
2,086
Embed Views
2,402

Actions

Likes
0
Downloads
62
Comments
0

23 Embeds 2,402

http://elrayescampaign.blogspot.ca 2139
http://elrayescampaign.blogspot.com 196
http://elrayescampaign.blogspot.de 13
http://elrayescampaign.blogspot.in 10
http://elrayescampaign.blogspot.kr 6
http://www.elrayescampaign.blogspot.com 5
http://elrayescampaign.blogspot.com.es 4
http://elrayescampaign.blogspot.mx 4
http://www.elrayescampaign.blogspot.be 3
http://elrayescampaign.blogspot.com.br 3
http://elrayescampaign.blogspot.co.uk 3
http://elrayescampaign.blogspot.fr 3
http://elrayescampaign.blogspot.nl 2
http://translate.googleusercontent.com 2
http://elrayescampaign.blogspot.se 1
http://webcache.googleusercontent.com 1
http://elrayescampaign.blogspot.it 1
http://elrayescampaign.blogspot.sg 1
http://elrayescampaign.blogspot.fi 1
http://elrayescampaign.blogspot.cz 1
http://elrayescampaign.blogspot.gr 1
http://elrayescampaign.blogspot.ro 1
https://translate.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to MPLAB IDE Introduction to MPLAB IDE Presentation Transcript

  • MPLAB IDE Starter Guide By: Karim El-Rayes
  • Software to be installed • MPLAB IDE from Microchip®, its free of charge and you can download from Microchip® website. • C18 or C30 or C32 compiler according to the microcontroller family you are using, you can download Trail version or Lite version for students from Microchip® website. • Notes: For PIC18 family you will need C18 C – compiler. For PIC24 and PIC33 families you will need C30 C – compiler. For PIC32 family you will need C32 C – compiler. • PIC18F4550 was used as an example in many cases, but most of the material is applicable for all PIC18F family of microcontrollers.
  • Step 1
  • Click next
  • Step 2 Select microcontroller you will use from this list, then click “Next”
  • Step 3 Select compiler C18 from the list, don’t forget to select the other settings, then click “Next”
  • Step 4 Choose place to save your project, then click “Next”
  • Add any files to the project if you want, then click “Next”
  • Click “Finish”
  • Step 5 Click “New file” button to start writing your first code
  • Write your code here then click “Save file” button
  • Choose place to save your code and don’t forget to save it in *.c
  • Step 6 Right click on “Source Files” and select “Add Files”
  • Choose your code *.c file you saved it
  • Step 7 (optional) Right click on “Linker script” and select “Add Files”
  • Go to C:MCC18binlkr And select linker script file of the microcontroller you are using in your project (in this example we are using microcontroller PIC18F4550) In C18 compiler Version 3.36 and higher, the linker scripts are in C:MCC18binLKR
  • Step 8 Select “Release” if you want to download the generated .hex file on the microcontroller
  • Step 9 Click “Project” then go to “Build options” then select “Project”
  • Select “Library Search Path” from the directories drop list
  • Click “New” then write here the libraries file path then click “Apply” then “Ok”
  • Step 10 Click “Build All” button to build and compile your project
  • Check your program either “Build succeeded” or watch the errors here
  • Hints: Setting microcontroller clock Click “Configure” then select “Configuration Bits”
  • If you want to make settings from this window and not in your code don’t check this mark. If you are using crystal higher than 4MHz choose “HS-PLL Enabled”. If you are using 4MHz crystal choose XT. Disable “Watchdog timer” if you are not using it.
  • Hints: settings for PIC18F4550 Set the crystal you are using If you are using a crystal higher than 4MHz select “HS” or “HS+PLL” Disable watchdog timer if you are not using it.
  • How to Program your PIC Choose programmer device from here (here we chose PICKit 3)
  • How to Program your PIC (cont.) Step 1: Choose “Release” Option Step 2: “Build” project Step 3: “Program” the PIC Note: After you program the PIC, disconnect the PIC programmer hardware from the microcontroller.
  • How to Debug your PIC Choose debugger device from here (here we chose PICKit 2)
  • How to Debug your PIC (cont.) Step 1: Choose “Debug” Option Step 2: “Build” project Step 4: “Run” to start debugging Step 3: “Program” the PIC
  • Hardware example: Connecting PICkit 2/PICkit 3 programmer/debugger to PIC18F4550 microcontroller +5v Ground Notes: • Pin 2 in PICkit2/3 “VDD/Target” has to be connected to the microcontroller VDD supply, if you are using +3.3v supply based microcontrollers then VDD = +3.3v, and the same for +5v supply. • Pin 6 in PICkit 2 is “Not connected”, while in PICkit 3 is Low Voltage Programming pin “LVP”, leave it not connected in most cases if you are not using it.
  • Circuit schematic for PIC18F4550 microcontroller with USB module connection to PC Notes: • VCC = +5v, you can power the PIC from the USB port itself. • You can replace the 8 MHz crystal with any value depending on your configuration. • The two 100nF capacitors on Pin 18 can be replaced with one 470nF capacitor.
  • Example code 1: Simple digital output using PIC18F4550 // In this example we will configure port D as output and send some data to be //output on it #include<p18f4550.h> void main() { TRISD = 0x00; //set port D to output , also can be written 0b00000000 LATD = 0x00; //set latch of port D to 0x00 while(1) //while(1) loop is used to run the application forever { PORTD = 0x0f; // output 00001111 on port D pins } }
  • Example code 2: Simple digital input using PIC18F4550 // In this example we will configure port D as input and read some data from and //store it to variable “i” #include<p18f4550.h> int i = 0; void main() { TRISD = 0xff; //set port D to input, also can be written 0b11111111 LATD = 0x00; //set latch of port D to 0x00 while(1) //while(1) loop is used to run the application forever { i = PORTD; // read port D and save read value to variable i } }
  • Using PIC32 Starter kit or PIC32 microcontrollers
  • PIC32 Starter kits PIC32 Ethernet Starter kit PIC32 USB Starter kit II
  • Connecting PIC32 ESK board PIC32 Ethernet Starter kit PIC32 USB Starter kit II
  • Selecting PIC32 starter kit for debugging Select “PIC32 Starter kit” from the debuggers list
  • Debugging Step 1: set the debugger to “Debug” mode Step 2: “Build” project Step 3: “Program” the PIC microcontroller Step 4: “Start” debugging