EE/CSC 312 Lab #1
Introduction to PIC Programming and the MPLAB IDE
Preliminary
Navigate to microchip.com → Design → Development Tools → Software Tools for PIC
Download and install the current version of MPLAB-X IDE
Download and install the MPLAB-XC8 C compiler.
Install the MCC plugin from within the IDE
(Tools → Plugins → MPLAB Code Configurator)
Download the associated User’s guides for the IDE and compiler.
MPLAB-X IDE User Guide
MPLAB XC8 Compiler Legacy User’s Guide
MPLAB XC8 User Guide for PIC
Lab – All exercises are to be done using the IDE and the simulator, using the PIC16F1619 as the target processor. Execute the programs in the simulator environment.
- Set the IDE debugger to “Halt at Main”
Tools → Options → Embedded → Debug Startup
- Create a C code project in the MPLAB-X IDE. Select the PIC16F1619 device and select the simulator as the debugging tool.
- Open the MCC and configure Port A bit 5 as an output. Generate.
- Inspect the Project files.
- Select Compile/Debug
- Set up the IOpin tool to show the state of RA5.
Window → Simulator → Iopin
Enable Run Time Update option
- Add these instructions in the while loop:
LATAbits.LATA5=0;
LATAbits.LATA5=1;
- Execute the program using F8 to single step. Observe the IOPIN indicator.
- Execute the program using breakpoints.
- Add __delay_ms(10000) in the loop. Rebuild.
- Using the simulator stopwatch function, Window → Debugging → Stopwatch, determine how long the program takes to execute.
Challenge:
- Use the Stimulus tool (Window → Simulator → Stimulus) to simulate a switch that provides an input signal to stop/continue the blinking light.
Choose a pin to use, use the MCC to configure it as input, set up the stimulus action to toggle, write a program that uses the input to enble/disable the blinking.