Page 1 Microchip Technology Inc. Digital Signal Controller (C) Development Tools 2004 Microchip Technology Inc Development Tools Slide 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.
Page 2 MPLAB IDE Components for dspic C Languages ASM/LINK30 LIB/tools MPLAB C30 Visual Device Initializer MPLAB Integrated Development Environment Built-in Editor Libraries Encryption Soft Modem Math P Encryption Echo Cancel Noise Suppress Speech Recog Source Level Debugger Simulators Emulators MPLAB SIM Stimulus Control MPLAB ICE 4000 Project Manager Programmers MPLAB PM3 MPLAB ICD 2 2004 Microchip Technology Inc Development Tools Slide 2 Demo/Eval 28-pin Starter GP Dev Board dspicdem.net 1 dspicdem.net 2 dspicdem MC1 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 MPLAB IDE Desktop 2004 Microchip Technology Inc Development Tools Slide 3 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 MPLAB IDE Desktop 2004 Microchip Technology Inc Development Tools Slide 4 Pull-down menus at the top allow access to all features of MPLAB IDE.
Page 5 Project Window 2004 Microchip Technology Inc Development Tools Slide 5 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 Breakpoints Breakpoints halt the code to inspect and change variables and special function registers, and to single step through the code Breakpoints can be set by specifying a location in the code with an address or a label Breakpoints can be set on a line of code with the right mouse button 2004 Microchip Technology Inc Development Tools Slide 6 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 Setting Breakpoints 2004 Microchip Technology Inc Development Tools Slide 7 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 Complex Breakpoints MPLAB ICD 2 and MPLAB ICE 4000 can set complex breakpoints Complex breakpoints allow pre-qualifiers, pass counters, and breaking on data Example: After GetSpeed executes, then after ReadRPM executes, then after Scount[] receives 20 bytes, break when Rcount > 128. 2004 Microchip Technology Inc Development Tools Slide 8 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 singlestepping.
Page 9 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 9 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 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 10 In the watch window above, the structure named RTclock consists of four elements,
Page 11 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 11 a 16-bit variable called timer,
Page 12 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 12 a 16-bit variable named ticks
Page 13 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 13 an 8-bit variable named seconds,
Page 14 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 14 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. The floating point value for total_time is shown in exponential notation.
Page 15 Watch Windows 2004 Microchip Technology Inc Development Tools Slide 15 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 Source View 2004 Microchip Technology Inc Development Tools Slide 16 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 Source View 2004 Microchip Technology Inc Development Tools Slide 17 Placing the cursor on a line in the source code and pressing the right mouse button brings up this menu. Select Set Breakpoint to set a breakpoint on this first line in this function.
Page 18 Source View 2004 Microchip Technology Inc Development Tools Slide 18 If you execute Run, it stops at this breakpoint, as indicated by the green arrow on top of the red breakpoint icon.
Page 19 Source View 2004 Microchip Technology Inc Development Tools Slide 19 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 Source View 2004 Microchip Technology Inc Development Tools Slide 20 step
Page 21 Source View 2004 Microchip Technology Inc Development Tools Slide 21 step
Page 22 Source View 2004 Microchip Technology Inc Development Tools Slide 22 step takes you through the code one source line at a time.
Page 23 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 23 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 previously.
Page 24 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 24 Set a breakpoint like before
Page 25 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 25 Then run to the break
Page 26 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 26..and single step, one assembly instruction at a time.
Page 27 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 27 step
Page 28 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 28 step
Page 29 Machine Code View 2004 Microchip Technology Inc Development Tools Slide 29 step
Page 30 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 30 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 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 31 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 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 32 The generated machine hex code and the corresponding disassembled instructions are shown in blue.
Page 33 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 33 For the machine code instructions, the left column is the address of the instruction in program memory
Page 34 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 34 followed by the hexadecimal values for the instruction.
Page 35 Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 35 A breakpoint can also be set in the Disassembly Listing View window.
Page 36 Mixed Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 36..and you can run and halt at this breakpoint
Page 37 Mixed Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 37 And single step as before
Page 38 Mixed Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 38 step
Page 39 Mixed Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 39 step
Page 40 Mixed Disassembly Listing View 2004 Microchip Technology Inc Development Tools Slide 40 step
Page 41 MPLAB SIM Most Cost-Effective Debugger dspic Simulation Core ALU P Engine Program Memory Data Memory dspic Simulated Peripherals Timers UARTs A/D I/O Pins Most other peripherals 2004 Microchip Technology Inc Development Tools Slide 41 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 P 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 MPLAB SIM 2004 Microchip Technology Inc Development Tools Slide 42 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 Timing Code 2004 Microchip Technology Inc Development Tools Slide 43 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 Code Timing 2004 Microchip Technology Inc Development Tools Slide 44 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 Simulator Trace 2004 Microchip Technology Inc Development Tools Slide 45 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 and disassembled instruction,
Page 46 Simulator Trace 2004 Microchip Technology Inc Development Tools Slide 46 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 Simulator Trace 2004 Microchip Technology Inc Development Tools Slide 47 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 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 2004 Microchip Technology Inc Development Tools Slide 48 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 Manual Stimulus Control 2004 Microchip Technology Inc Development Tools Slide 49 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. When a pin is to be activated, the line is selected, and the Fire button initiates the action.
Page 50 Clock Stimulus Control 2004 Microchip Technology Inc Development Tools Slide 50 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 File Stimulus Control 2004 Microchip Technology Inc Development Tools Slide 51 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 Complex List Stimulus Control 2004 Microchip Technology Inc Development Tools Slide 52 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 Using print(f) 2004 Microchip Technology Inc Development Tools Slide 53 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 printf() Output 2004 Microchip Technology Inc Development Tools Slide 54 The output window now contains a record of the values of the array each time the loop runs.
Page 55 Data Can Be Imported/Exported 2004 Microchip Technology Inc Development Tools Slide 55 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 MPLAB ICD 2 2004 Microchip Technology Inc Development Tools Slide 56 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 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 ) 2004 Microchip Technology Inc Development Tools Slide 57 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 MPLAB PM3 Universal Programmer Production-graded programmer for PICmicro MCUs and dspic30f Stand-alone operation In-Circuit Serial Programming (ICSP ) built in Fast programming times! Serial Quick Turn Programming (SQTP SM ) support SD/MMC support 2004 Microchip Technology Inc Development Tools Slide 58 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 Hardware Development dspicdem 28-Pin Starter Demo Board dspicdem General Purpose Development Board dspicdem.net 1 Connectivity Development Board (FCC/JATE) dspicdem.net 2 Connectivity Development Board (CTR-21) dspicdem MC1 Motor Control Development System 2004 Microchip Technology Inc Development Tools Slide 59 A number of demonstration evaluation boards are available. These include working software and source code and a prototyping area for custom circuitry.
Page 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 2004 Microchip Technology Inc Development Tools Slide 60 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 dspicdem MC1 Motor Control Development Boards 2004 Microchip Technology Inc Development Tools Slide 61 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 dspicdem.net Internet/Ethernet Demo Board Connect to a Network using a PICmicro MCU with TCP/IP stack software. 2004 Microchip Technology Inc Development Tools Slide 62 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 dspic Design Tools and Real Time Operating Systems 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 2004 Microchip Technology Inc Development Tools Slide 63 *subject to change 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 And tools from CMX for RTOS and conectivity.
Page 64 dspic Libraries dspic Math Library dspic Peripheral Library dspic P 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 2004 Microchip Technology Inc Development Tools Slide 64 *subject to change 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 P Algorithm Library Acoustic Echo Cancellation Noise Suppression Speech Recognition And Encryption Libraries.
Page 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 2004 Microchip Technology Inc Development Tools Slide 65 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 For More Information www.microchip.com 2004 Microchip Technology Inc Development Tools Slide 66 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 application based upon the dspic device couldn t be much easier.