MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the...

52
University of Florida Electrical and Computer Engineering EEL3923 & EEL4924 Microchip MPLAB and C18 compiler setup.

Transcript of MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the...

Page 1: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

University of Florida 

Electrical and Computer Engineering 

EEL3923 & EEL4924 Microchip MPLAB and C18 compiler setup. 

    

Page 2: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

  

Start the MPLAB setup program. 

 Click next. 

   

Page 3: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Accept and click next. 

   

Page 4: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

   

Page 5: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

   

Page 6: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

   

Page 7: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

   

Page 8: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

The software will now install. 

   

Page 9: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click No. 

   

Page 10: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click No and then the Finish button, we will restart later. 

   

Page 11: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Next we will install the compiler.  Navigate to the MPLAB‐C18‐Lite directory and start the application. 

Click Next. 

   

Page 12: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Select I Accept and click next. 

   

Page 13: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Click next. 

   

Page 14: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Click Next. 

   

Page 15: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Select all four boxes and click next. 

   

Page 16: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 

  

Select all four boxes and click next. 

   

Page 17: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click next. 

The software will now install. 

   

Page 18: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Next click Finish. 

Unselect the boxes you don’t want to open and read. 

   

Page 19: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Now reboot. 

 After you log in this window will pop up. 

You can just close it. 

 Click this icon to start MPLAB IDE. 

   

Page 20: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

The software is now installed. 

The next section will cover the setting 

 up and building of a new project.

Page 21: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 This is what you should see when the program starts. 

   

Page 22: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 In the toolbar select Project and then Project Wizard. 

   

Page 23: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click Next. 

   

Page 24: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Select PIC18F1320. 

   

Page 25: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Make sure that the Active Toolsuite is Microchip C18 Toolsuite. 

   

Page 26: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Also make sure that the toolsuite contents and the locations match. 

Click Next. 

   

Page 27: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Next Select the Program button from the toolbar and click on Project wizard. 

Enter the name of your project.  18F1320Wizard in this case. 

   

Page 28: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

You can also select the project location with the Browse button. 

 This is where you can add your main.c file. 

   

Page 29: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 This is the Main.c file that is used for this example. 

   

Page 30: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 You must also add the linker file to match your processor. 

   

Page 31: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 In this case it is a 18F1320.  After clicking the 18F1320_g file click Add. 

   

Page 32: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Click Finish. 

   

Page 33: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Next select the Project tool box and then select the Set Language Tool Locations tool. 

   

Page 34: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 Select the Microchip C18 Toolsuite toolbox. 

   

Page 35: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

 

 

 Open the executables box. 

   

Page 36: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Check that the executables are pointed to the correct locations as above. 

   

Page 37: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Next select the project tool and then select the Build Options…Project. 

Page 38: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Now select the Directories tab.  Then select the Include Search Path in the drop down box.  Next click 

new. 

 Click this button to open up the Directory to select the files. 

   

Page 39: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 Set the search path for the include and the library to match the above. 

Click apply and then OK. 

 

 Click the Build All button shown above. 

This will build and compile your project.

 The last line in the output box should read “BUILD SUCCEEDED”. 

Page 40: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Select the Debugger tool_SelectTool_4 MPLAB SIM as above. 

   

Page 41: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Select the View tool and then select the Watch option.  This will open a new window. 

   

Page 42: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

In the watch window you can select the symbol section and select a variable to monitor.  X has been 

selected here.  After the variable is selected click the Add Symbol button.  

   

Page 43: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

In the watch window you can select the SFR section and select a SFR to monitor.  Port B has been 

selected here.  After the SFR is selected click the Add SFR button.  

   

Page 44: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

On the top of the page find the run button and click it. 

 

Pause the sim.  You should be able to see your port and variable data in the watch window. 

   

Page 45: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

 

Next select the Debugger tool and click the settings button. 

   

Page 46: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Click the UART1 IO tab and set the boxes as shown above.  This will route the printf data to the Output 

screen. 

   

Page 47: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Running your program on your target device. 

 

Select the debugger tool and click on Select Device and then 7PICkit 2. 

   

Page 48: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Select the debugger tool again and then click the settings button. 

   

Page 49: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Adjust your settings to match the above window. 

   

Page 50: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

Your program should be running on your hardware now. 

   

Page 51: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

If you right click in your main.c window you can set a breakpoint.  

   

Page 52: MPLAB C18 Setup - University of Florida · Next we will install the compiler. Navigate to the MPLAB‐C18‐Lite directory and start the application. Click Next.

You will see a red circle with a “B” marking the breakpoint.  The program will run until it reaches this 

point and then it will stop.  To continue click the run button again. 

 

 You can single step your program by pressing the step Into button here.