Getting Started with Development Tools
Development Tools Home
Getting Started Development Tools Home
Step 1 An Overview of Embedded Systems
Step 2 Start Now with Microchip Development Tools
Step 3 Implementing an Embedded System Design with MPLAB® IDE
Step 4 The Development Cycle
Step 5 MPLAB® Project Manager
Step 6 Language Tools
Step 7 Target Debugging
Step 8 Programming
Step 9 MPLAB® IDE: For More Information
Getting Started with MPLAB Editor
Getting Started with MPASM/MPLINK
Getting Started with MPLAB SIM
Getting Started with MPLAB ICD
Getting Started with MPLAB C18 1
Getting Started with MPLAB C18 2
Getting Started with MPLAB C18 3
Introduction to Microchip’s Development Tools
Introduction to MPLAB® IDE
Tips and Tricks Using MPLAB® IDE v6.61
Introduction to MPLAB® SIM Software Simulator
Basic dsPIC Development Tools
Introduction to the Signal Analysis PICtail daughterboard
Choosing a Debug Tool
MPLAB® IDE User's Guide
MPLAB® IDE Quick Chart
MPLAB® Download Page
Online Discussion Groups
Development Tools Selector Guide
Available Books
Third Party Tools
  Featured Products
 

Pick your MCU
 
 
     

STEP 3 - Implementing an Embedded System Design with MPLAB® IDE

A development system for embedded controllers is a system of programs running on a desktop PC to help write, edit, debug and program code –-the intelligence of embedded systems applications–- into a microcontroller. MPLAB IDE, runs on a PC and contains all the components needed to design and deploy embedded systems applications.

The typical tasks for developing an embedded controller application are:

1. Create the high level design. From the features and performance desired, decide which PIC® MCU or dsPIC® DSC device is best suited to the application, then design the associated hardware circuitry.

After determining which peripherals and pins control the hardware, write the firmware – the software that will control the hardware aspects of the embedded application. A language tool such as an assembler, which is directly translatable into machine code, or a compiler that allows a more natural language for creating programs should be used to write and edit code.

Assemblers and compilers help make the code understandable, allowing function labels to identify code routines with variables that have names associated with their use, and with constructs that help organize the code in a maintainable structure.

Timing Diagram from Data Book

2. Compile, assemble and link the software using the assembler and/or compiler and linker to convert your code into “ones and zeroes” –-machine code for the PIC MCUs. This machine code will eventually become the firmware (the code programmed into the microcontroller).

3. Test your code. Usually a complex program does not work exactly the way imagined, and “bugs” need to be removed from the design to get proper results. The debugger allows you to see the “ones and zeroes” execute, related to the source code you wrote, with the symbols and function names from your program.

Debugging allows you to experiment with your code to see the value of variables at various points in the program, and to do “what if” checks, changing variable values and stepping through routines.

4. “Burn” the code into a microcontroller and verify that it executes correctly in the finished application.


PIC MCU Instruction Documentation
from Data Book

Of course, each of these steps can be quite complex. The important thing is to concentrate on the details of your own design, while relying upon MPLAB IDE and its components to get through each step without continuously encountering new learning curves.

Step 1 is driven by the designer, although MPLAB IDE can help in modeling circuits and code so that crucial design decisions can be made.

MPLAB IDE provides the designer with streamlined power in steps 2 through 5.

    Its Programmer’s Editor helps write correct code with the language tools of choice. The editor is aware of the assembler and compiler programming constructs and automatically “color-keys” the source code to help ensure it is syntactically correct.

    The Project Manager enables you to organize the various files used in your application: source files, processor description header files and library files. When the code is built, you can control how rigorously code will be optimized for size or speed by the compiler and where individual variables and program data will be programmed into the device. You can also specify a “memory model” in order to make the best use of the microcontroller’s memory for your application.

    If the language tools run into errors when building the application, the offending line is shown and can be “double-clicked” to go to the corresponding source file for immediate editing. After editing, press the “build” button to try again. Often this write-compile-fix loop is done many times for complex code, as the sub-sections are written and tested. MPLAB IDE goes through this loop with maximum speed, allowing you to get on to the next step.

Testing using Debuggers and Simulators
Once the code builds with no errors, it needs to be tested.

Even if the hardware is not yet finished, you can begin testing the code with the simulator, a software program that simulates the execution of the microcontroller. The simulator can accept a simulated input (stimulus), in order to model how the firmware responds to external signals. The simulator can measure code execution time, single-step through code to watch variables and peripherals, and trace the code to generate a detailed record of how the program ran.

Once the hardware is in a prototype stage, a hardware debugger, such as MPLAB REAL ICE or MPLAB ICD 2 can be used. These debuggers run the code in real time on your actual application.

MPLAB REAL ICE and MPLAB ICD 2 use special circuitry built into many Microchip MCUs with Flash program memory and can “see into” the target microcontroller's program and data memory. They can stop and start program execution, allowing you to test the code with the microcontroller in place on the application.

After the application is running correctly, you can program a microcontroller with one of Microchip’s device programmers, such as PICSTART® Plus or MPLAB PM3. These programmers “burn” the finished code into devices. MPLAB REAL ICE and MPLAB ICD 2, although principally debuggers, can also be used to program devices.

When programming a device, the programmers can write to the configuration bits of the MCU, special locations that determine the oscillator type, enable or disable the watchdog timer and brownout detection circuits and control other configuration parameters. Some MCUs have security bits that allow all or a portion of the memory to be programmed, but “locked” and unable to be read again. This provides security for code as well as data that is programmed into a device.

PIC MCU Configuration Register Information from Data Book

Step 2: Start Now With Microchip Development Tools

Step 4: The Development Cycle