Page 1
Welcome to the dsPIC Development Tools web seminar.
My name is Darrel Johansen and I’m a manager in the Development Systems group here at Microchip Technology.
The dsPIC is the latest embedded controller architecture from Microchip Technology. It combines a 16-bit microcontroller with digital signal
processing, on-chip flash memory, and a powerful selection of peripherals in a small package.
This seminar will go into some of the tools, libraries and development boards that are available to help you get an application using the dsPIC out to
market quickly.
DS
2004 Microchip Technology Inc DS Development Tools Slide 1
DS
Digital Signal
Controller (DSC)
Development Tools
Page 2
DS
2004 Microchip Technology Inc DS Development Tools Slide 2
MPLAB ICD 2 Project Manager Built-in Editor Source Level Debugger ASM/LINK30 LIB/tools Languages Programmers MPLAB SIM Simulators Emulators MPLAB C30 MPLAB®
Integrated Development Environment
MPLAB PM3 Visual Device Initializer MPLAB ICE 4000
MPLAB
®IDE
Components for dsPIC
®DSC
Encryption Libraries Soft Modem Math DSP Encryption Echo Cancel Noise Suppress Stimulus Control Demo/Eval 28-pin Starter GP Dev Board dsPICDEM.net™ 1 dsPICDEM.net 2 dsPICDEM™ MC1 Speech Recog
MPLAB IDE is Microchip’s Integrated Development Environment for developing embedded applications. MPLAB IDE contains a number of components specifically for dsPIC
development.
The Microchip dsPIC tool suite running under the MPLAB IDE has Language and Library support, Simulator, Emulator, Programmer and Evaluation board components.
The tools in yellow are standard components of MPLAB IDE, available at no charge, and can be downloaded from the Microchip web site along with the MPLAB IDE software.
Since MPLAB’s editor, project manager, simulator and assembler are available for free, you can write and test code for dsPIC devices by simply downloading MPLAB IDE and installing it on your PC.
Also free is the Visual Device Initializer, or VDI. It can be used to graphically set up the dsPIC peripherals and core.
Many libraries are available to assist in specific applications. They are all available for download.
The items in green are available as components to be purchased from Microchip as options for MPLAB IDE. These optional components include the MPLAB C30 C compiler, MPLAB ICE 4000 in-circuit emulator, MPLAB PM3 device programmer, and MPLAB ICD 2 In-circuit debugger.
The last column shows fully functional circuit boards with source code which can be used for evaluation and for prototyping custom circuitry.
Page 3
DS
2004 Microchip Technology Inc DS Development Tools Slide 3
MPLAB
®IDE Desktop
I’ll take a few minutes to walk through the highlights of MPLAB IDE. These are covered in more detail in other seminars, and you should view them to get better understanding of the power and capabilities of MPLAB IDE. The MPLAB IDE desktop looks like many other Windows applications.
Page 4
DS
2004 Microchip Technology Inc DS Development Tools Slide 4
MPLAB
®IDE Desktop
Page 5
DS
2004 Microchip Technology Inc DS Development Tools Slide 5
Project Window
The MPLAB IDE Project Window keeps track of your source files, as well as compilers, assembler and linker settings, switches and optimizations. The project manager builds the files into the final application.
Page 6
DS
2004 Microchip Technology Inc DS Development Tools Slide 6
Breakpoints
Y Breakpoints halt the code to inspect and change variables and special function registers, and to single step through the code
Y Breakpoints can be set by specifying a location in the code with an address or a label
Y Breakpoints can be set on a line of code with the right mouse button
Breakpoints are part of the MPLAB In-circuit Debugger. Breakpoints allow you to halt the code and inspect variables and registers and then single step through the code.
•Breakpoints can be used with the simulator, the in-circuit debugger or the in-circuit emulator.
•Breakpoints can be set by specifying a location in the code with an address or a label from your source code
•Breakpoints can also be set on a specific line of code with the right mouse button
Page 7
DS
2004 Microchip Technology Inc DS Development Tools Slide 7
Setting Breakpoints
When the right mouse button is clicked, this menu pops-up and allows you to set a breakpoint.
Note that there are other features on the menu, including “Run to Cursor,” “Set Bookmarks,” and search functions. This window is the editor window, and is where you can write and test your code. Both debug and editing functions are available while in this window. This allows you to quickly test, then modify your code.
Advanced functions allow searching for matching braces, and commenting out blocks of code.
Page 8
DS
2004 Microchip Technology Inc DS Development Tools Slide 8
Complex Breakpoints
Y MPLAB® ICD 2 and MPLAB ICE 4000 can set complex breakpoints
Y Complex breakpoints allow pre-qualifiers, pass counters, and breaking on data Y Example:
After GetSpeed executes, then after ReadRPM executes,
then after Scount[] receives 20 bytes, break when Rcount > 128.
Complex breakpoints can be used with the hardware debuggers to capture events in real time.
Complex breakpoints allow conditions to be described to halt the processor at a breakpoint. An example would be to wait until the function named “GetSpeed” calls a subroutine named “ReadRPM” and then wait while 20 bytes of data are written into the array named “Scount,” then break when the variable “Rcount” becomes greater than 128.
Complex breakpoints assign a detailed description to halt the application code in order to zero in on a problem area. If you know the conditions where a problem exists in an application, often a complex breakpoint can find the problem much more quickly than simple address breakpoints and single-stepping.
Page 9
DS
2004 Microchip Technology Inc DS Development Tools Slide 9
Watch Windows
Watch windows can display complex structures, formatted with the values according the data types as defined in your source code.
Variables can be dragged and dropped from the source code to be placed in the watch window, can be selected from drop down lists or can simply be typed in by name or address.
Page 10
DS
2004 Microchip Technology Inc DS Development Tools Slide 10
Watch Windows
In the watch window above, the structure named “RTclock” consists of four elements,
Page 11
DS
2004 Microchip Technology Inc DS Development Tools Slide 11
Watch Windows
Page 12
DS
2004 Microchip Technology Inc DS Development Tools Slide 12
Watch Windows
Page 13
DS
2004 Microchip Technology Inc DS Development Tools Slide 13
Watch Windows
Page 14
DS
2004 Microchip Technology Inc DS Development Tools Slide 14
Watch Windows
and a floating point variable called “total time.”
MPLAB IDE automatically shows the values in the proper format for each variable.
Note that “seconds” has only two digits, since it is an 8-bit value, while “timer” and “ticks” have four because they are 16-bit values.
Page 15
DS
2004 Microchip Technology Inc DS Development Tools Slide 15
Watch Windows
Below the structure “RTclock” the variable “sticks” in this watch window is labeled as “Out of Scope.”
This means that “sticks” is a local variable, and the current breakpoint is not in the function where “sticks” is relevant.
At the breakpoint, changes in values are indicated with red text.
You can modify the contents of a variable by clicking on the value in the watch window and typing in a new number.
Page 16
DS
2004 Microchip Technology Inc DS Development Tools Slide 16
Source View
MPLAB IDE shows the code in different windows with different formats. Single stepping through source files allows you to step through lines of source code and inspect values of variables and registers at each step.
Page 17
DS
2004 Microchip Technology Inc DS Development Tools Slide 17
Source View
Placing the cursor on a line in the source code and pressing the right mouse button brings up this menu.
Page 18
DS
2004 Microchip Technology Inc DS Development Tools Slide 18
Source View
If you execute “Run,” it stops at this breakpoint, as indicated by the green arrow on top of the red breakpoint icon.
Page 19
DS
2004 Microchip Technology Inc DS Development Tools Slide 19
Source View
Now you can single-step through the code. The breakpoint is still set at the previous line, so if you were to reset and run again, the code would be halted there again.
Page 20
DS
2004 Microchip Technology Inc DS Development Tools Slide 20
Source View
Page 21
DS
2004 Microchip Technology Inc DS Development Tools Slide 21
Source View
Page 22
DS
2004 Microchip Technology Inc DS Development Tools Slide 22
Source View
Page 23
DS
2004 Microchip Technology Inc DS Development Tools Slide 23
Machine Code View
Alternatively code can be viewed as dsPIC machine code in the Program Memory window.
Single stepping through the Program Memory window steps through all the dsPIC assembly instructions, not just the lines of C code as shown
Page 24
DS
2004 Microchip Technology Inc DS Development Tools Slide 24
Machine Code View
Page 25
DS
2004 Microchip Technology Inc DS Development Tools Slide 25
Machine Code View
Page 26
DS
2004 Microchip Technology Inc DS Development Tools Slide 26
Machine Code View
Page 27
DS
2004 Microchip Technology Inc DS Development Tools Slide 27
Machine Code View
Page 28
DS
2004 Microchip Technology Inc DS Development Tools Slide 28
Machine Code View
Page 29
DS
2004 Microchip Technology Inc DS Development Tools Slide 29
Machine Code View
Page 30
DS
2004 Microchip Technology Inc DS Development Tools Slide 30
Disassembly Listing View
In a Disassembly Listing View window display, the original C source code is shown interspersed with the dsPIC assembly code that it generated.
This view shows the information in both the preceding views, allowing you to see the machine instructions generated by the C source code.
Page 31
DS
2004 Microchip Technology Inc DS Development Tools Slide 31
Disassembly Listing View
The C source code is shown in black with the line number from the source code file shown on the left column in green.
Page 32
DS
2004 Microchip Technology Inc DS Development Tools Slide 32
Disassembly Listing View
The generated machine hex code and the corresponding disassembled instructions are shown in blue.
Page 33
DS
2004 Microchip Technology Inc DS Development Tools Slide 33
Disassembly Listing View
For the machine code instructions, the left column is the address of the instruction in program memory
Page 34
DS
2004 Microchip Technology Inc DS Development Tools Slide 34
Disassembly Listing View
Page 35
DS
2004 Microchip Technology Inc DS Development Tools Slide 35
Disassembly Listing View
Page 36
DS
2004 Microchip Technology Inc DS Development Tools Slide 36
Mixed Disassembly Listing View
Page 37
DS
2004 Microchip Technology Inc DS Development Tools Slide 37
Mixed Disassembly Listing View
Page 38
DS
2004 Microchip Technology Inc DS Development Tools Slide 38
Mixed Disassembly Listing View
Page 39
DS
2004 Microchip Technology Inc DS Development Tools Slide 39
Mixed Disassembly Listing View
Page 40
DS
2004 Microchip Technology Inc DS Development Tools Slide 40
Mixed Disassembly Listing View
Page 41
DS
2004 Microchip Technology Inc DS Development Tools Slide 41
MPLAB
®SIM
Most Cost-Effective Debugger dsPIC® Simulation Core
•ALU
•DSP Engine •Program Memory •Data Memory
dsPIC Simulated Peripherals •Timers
•UARTs •A/D •I/O Pins
•Most other peripherals
The simulator has been used to demonstrate the debug features of MPLAB IDE. MPLAB SIM is a cost-effective way to test and debug code.
Free with MPLAB IDE software, the simulator is a software tool running on the PC that allows you to run dsPIC code, set breakpoints, single-step, and watch variables as the code executes.
The simulator models the dsPIC core, including the ALU and DSP engine, as well as the program memory, data memory, plus the core and peripheral traps and interrupts.
Important peripherals are simulated including the general purpose timer, the UART, and the I/O pins.
Page 42
DS
2004 Microchip Technology Inc DS Development Tools Slide 42
MPLAB
®SIM
The simulator also allows you to accurately measure code time as it
executes. Depending upon the speed of your PC and how many peripherals are running in simulation, the simulator typically does not run at the full speed of the actual part, but it’s time calculations are exact calculations for when the actual device is running in your target.
When you enter the frequency of the target in the simulator settings, the simulator’s instruction execution is calculated exactly with this setting.
Page 43
DS
2004 Microchip Technology Inc DS Development Tools Slide 43
Timing Code
Once you’ve set the frequency for the clock, time measurements of the code can be done.
With the Stopwatch code segments can be timed according to the number of instruction cycles, or the speed of the final design as set in the previous dialog.
Page 44
DS
2004 Microchip Technology Inc DS Development Tools Slide 44
Code Timing
To time a section of code, a breakpoint is set at the start of the code and another at the end of the section being analyzed.
The Stopwatch will accurately measure the number of instruction cycles executed and the calculated time of the code segment.
Page 45
DS
2004 Microchip Technology Inc DS Development Tools Slide 45
Simulator Trace
Another simulation tool is the Trace window.
The simulator trace contains a wealth of information to show how the program executes in time.
It captures instructions as they execute, marked with their •address in program memory,
•the opcode
Page 46
DS
2004 Microchip Technology Inc DS Development Tools Slide 46
Simulator Trace
data read/writes on the X and Y data bus as well as all register read/writes are shown in the columns denoted by SXA through DD, with a time stamp on each instruction so precise timing measurements can be made.
The data on the source buses is shown in six columns, showing the address and data for the x and y memory areas of the dsPIC as well as the standard file register bus.
Page 47
DS
2004 Microchip Technology Inc DS Development Tools Slide 47
Simulator Trace
The trace captures instructions as they execute, so it can show the flow of code as it responds to interrupts and follows calls and branches.
Note in the above trace, the branch opcode at address 1DC executes, and the code immediately goes to address 1E4.
When a branch occurs, an extra cycle is executed as the program counter is changed in the dsPIC.
So a “No-Op” instruction is seen as being executed for one cycle at 1E4 before the actual instruction, a “MOVE” instruction begins to execute. As each instruction executes, changes in registers are clearly shown, and each instruction gets tagged by a time stamp.
Page 48
DS
2004 Microchip Technology Inc DS Development Tools Slide 48
Simulator Stimulus
•The Simulator can be controlled by stimuli representing signals
external to the application
•Manually “fired”
•Synchronously clocked
•Defined in external files
•Set by complex lists of events
Another simulator tool is the stimulus.
The stimulus features allow you to provide “inputs” to the simulator in order to simulate the actions of signals from external sources.
You can manually fire a stimulus by using a dialog button.
You can define a synchronous stimulus that acts like a repeating clock waveform
You can make lists of data in external files to be applied to registers or pins. And you can define complex conditions for starting and stopping stimulus sequences.
Page 49
DS
2004 Microchip Technology Inc DS Development Tools Slide 49
Manual Stimulus Control
The Stimulus Control dialog allows asynchronous stimulus events to be set up and “fired” at any time.
This allows you to manually simulate events happening on the pins of the dsPIC as the simulation executes.
This could simulate changing switches, or asynchronous external signals. There are a number of possible actions:
•Set pin high •Set pin low •Pulse pin high •Pulse pin low
•Toggle pin from the current state to the opposite state.
Pulse widths can be set, and comments can be added to each stimulus to document it’s usage.
Page 50
DS
2004 Microchip Technology Inc DS Development Tools Slide 50
Clock Stimulus Control
Synchronous clock signals can be set to occur repeatedly. The period of the signals is set in the “High” and “Low” columns, representing the number of cycles the signal will remain high and low, respectively.
The signals can be triggered to be started and ended at an address, or from another signal transition.
Page 51
DS
2004 Microchip Technology Inc DS Development Tools Slide 51
File Stimulus Control
More complex stimulus signals can be set up from external files. Here registers receive a series of input values stored in files. The file values are input as the registers are read by the program.
Page 52
DS
2004 Microchip Technology Inc DS Development Tools Slide 52
Complex List Stimulus Control
Another type of stimulus control allows listing a series of events that are applied to registers or pins.
These are identified as occurring at a fixed time after another event occurs. In this instance, after IC6BUF gets a value of 55, by whatever means, the sequence will begin.
30 microseconds later, IC4BUF will get a value of 58.
At a total of 54 microseconds after IC6BUF equaled 55, IC4BUF will get a new value of 66.
Page 53
DS
2004 Microchip Technology Inc DS Development Tools Slide 53
Using print(f)
MPLAB C30 “printf” functions can be used in code to route output to the MPLAB IDE Output window or to a file for complex debugging and analysis. Lines 60-63 have been added to this code for debugging purposes.
This debugging code will print a header title, “Product Array,” then print each element from “array_index” to an output window on MPLAB IDE each time the “printf” function executes.
Page 54
DS
2004 Microchip Technology Inc DS Development Tools Slide 54
printf() Output
The output window now contains a record of the values of the array each time the loop runs.
Page 55
DS
2004 Microchip Technology Inc DS Development Tools Slide 55
Data Can Be Imported/Exported
When using any debugger, including the simulator, data can be imported and exported into memory.
This allows data to be exported to an external graph for analysis, and allows large sets of complex data to be imported into memory for digital signal processing.
Page 56
DS
2004 Microchip Technology Inc DS Development Tools Slide 56
MPLAB
®ICD 2
While the simulator is handy and free with MPLAB IDE, when an application gets
programmed into a device, there may be subtle interactions with real-time signals that the simulator will not easily handle. Even though the simulator can tell you if sections of code are functioning correctly, it is difficult to anticipate all the interactions that will occur when the target hardware is operational. When you debug a running application, you often need a hardware debugger.
With a logic analyzer you can probe the circuits on your design to see if external signals are present on the input pins of the microcontroller, and you can attach probes to output pins to see activity there.
But to efficiently debug your application at this stage, you need to see what happens on these pins when particular sections of code execute. For this you need a hardware debugger. Microchip provides two types of hardware debuggers, MPLAB ICE and MPLAB ICD 2.
The MPLAB ICD 2 connects to the target application in order to program and debug the dsPIC device. and connects via a USB or RS-232 cable to the PC for control by MPLAB IDE.
Page 57
DS
2004 Microchip Technology Inc DS Development Tools Slide 57
MPLAB
®ICE 4000
{ Emulator Pod Kit
MPLAB ICE 4000 pod Power supply USB cable Literature MPLAB CD-ROM Tripod Logic probes Modular flex cable
| Processor Module
} Device Adapter (includes board and adapter plugs)
~ Transition Socket (optional )
{
|
}
~
For the ultimate in hardware debugging, MPLAB ICE 4000 helps find complex, real-time bugs quickly in your final application, while it runs at full speed.
MPLAB ICE 4000 consists of the main “Emulator Pod”, a “Processor Module,” which often supports a number of dsPIC devices, a “Device Adapter” for interconnection to your target application, and a optional “Transition Socket” to adapt to other package types.
The ICE offers unlimited breakpoints, whereas the ICD typically has three, at most. Plus the ICE offers a full hardware trace buffer to collect a record of the application’s code execution, register values, along with a time stamp on each instruction.
The other advantage the ICE has over the ICD is that it requires no pins for communication to the target. MPLAB ICD 2 needs to reserve some pins for communication as well as a small amount of memory for its operations.
Page 58
DS
2004 Microchip Technology Inc DS Development Tools Slide 58
MPLAB
®PM3
Universal Programmer
Y Production-graded
programmer for PICmicro®
MCUs and dsPIC30F Y Stand-alone operation Y In-Circuit Serial
Programming™ (ICSP™) built in
Y Fast programming times! Y Serial Quick Turn
Programming (SQTPSM)
support
Y SD/MMC support
DV007004
For programming dsPIC devices MPLAB PM3 offers a number of powerful features:
It can run either with MPLAB IDE and a PC or in a stand-alone mode. It has In-Circuit Serial Programming as a standard interface, so you can program your devices in circuit.
Serial Quick Term Programming support allows sequential IDs to be programmed into devices.
A standard SD/MMC memory card allows data to be quickly transported and saved.
Page 59
DS
2004 Microchip Technology Inc DS Development Tools Slide 59
Hardware Development
Y
dsPICDEM™ 28-Pin Starter Demo
Board
Y
dsPICDEM General Purpose
Development Board
Y
dsPICDEM.net™ 1 Connectivity
Development Board (FCC/JATE)
Y
dsPICDEM.net 2 Connectivity
Development Board (CTR-21)
Y
dsPICDEM MC1 Motor Control
Development System
A number of demonstration evaluation boards are available. These include working software and source code and a prototyping area for custom circuitry.
Page 60
DS
2004 Microchip Technology Inc DS Development Tools Slide 60
dsPICDEM™ 1.1 General Purpose
Development Board
• Emulator and ICD 2 interface
• RS-232
communication channel
• Analog and digital prototyping area
• CAN, RS-232, RS-485 • Voiceband codec • 122 x 32 dot
addressable LCD • Analog circuits, LED,
switches
The dsPIC general purpose development board provides the application designer with a low cost development tool.
The board features an active demonstration program loaded on the installed dsPIC306014 device. Several program functions are selectable via a menu system displayed on the LCD. These include: temperature and voltage measurements, frequency domain characteristics of a sine wave signal generated on-board, various digital filter selections and DTMF tone generator using the Codec interface peripheral.
Page 61
DS
2004 Microchip Technology Inc DS Development Tools Slide 61
dsPICDEM™ MC1 Motor Control
Development Boards
The Motor Control Development System provides the application developer with a system for quick prototyping and validation of motor control
applications.
The three main components are: •Motor Control Development Board,
•a 3-Phase Low Voltage Power Module and •a 3-Phase High Voltage Power Module.
Page 62
DS
2004 Microchip Technology Inc DS Development Tools Slide 62
dsPICDEM.net™ Internet/Ethernet
Demo Board
Connect to a
Network using
a PICmicro
®MCU with
TCP/IP stack
software.
The dsPICDEM.net™ 1 and dsPICDEM.net 2 connectivity development boards offer the application developer a basic platform for developing and evaluating both connectivity and non-connectivity based requirements. The dsPICDEM.net boards provide the hardware circuitry for supporting both the Public Switched Telephone Network and 10-Base T MAC interfaces.
Page 63
DS
2004 Microchip Technology Inc DS Development Tools Slide 63
dsPIC
®Design Tools and
Real Time Operating Systems
*subject to change dsPICworks™ Data Analysis
Digital Filter Design
IAR Embedded Workbench for dsPIC30F HI-TECH ANSI C Compiler for dsPIC30F CMX-Tiny™+ for dsPIC30F
CMX-MicroNet™ TCP/IP Connectivity and Protocol Support
CMX-RTX™ for dsPIC30F
CMX-Scheduler™ for dsPIC Devices
In addition to the tools mentioned, there are a number of other tools for dsPIC application development. Check out the Microchip Web site for information on
dsPICworks data analysis package Digital Filter Design
IAR’s embedded workbench for dsPIC HI-Tech C compiler
Page 64
DS
2004 Microchip Technology Inc DS Development Tools Slide 64
dsPIC
®Libraries
*subject to change • dsPIC Math Library
• dsPIC Peripheral Library • dsPIC DSP Algorithm Library • dsPIC Soft Modem Library
• dsPIC Acoustic Echo Cancellation Library • dsPIC Noise Suppression Library
• dsPIC Speech Recognition Library
• dsPIC Asymmetric Key Embedded Encryption Library • dsPIC Symmetric Key Embedded Encryption Library
Libraries are available and can be used with the free MPLAB ASM30 assembler or with the MPLAB C30 C compiler. These are high-speed, optimised libraries that can help you get your application to market without re-inventing the wheel.
Libraries include
•a general purpose Math Library •A Peripheral Library
•A DSP Algorithm Library •Acoustic Echo Cancellation •Noise Suppression
•Speech Recognition •And Encryption Libraries.
Page 65
DS
2004 Microchip Technology Inc DS Development Tools Slide 65
Third Party Tools
There are more than 120 third-party companies
supporting Microchip products. These vendors can be referenced from the Microchip Web site:
Programming/Emulation Adapters
Development Boards
In-Circuit Emulators
Gang Programmers
Device Programmers
Software Tools
Training Tools
In addition to these development tools from Microchip Technology, there are more than 120 third party companies supporting Microchip products. These vendors can be referenced from the Microchip web site.
Page 66
DS
2004 Microchip Technology Inc DS Development Tools Slide 66
For More Information
www.microchip.com
Thank you for your time. Please go to our Web site for complete
descriptions of all these tools, as well as our free development software package, MPLAB IDE. You’ll be sure to find that the steps for creating an