Micrium Tools Training: µC/Probe and SystemViewLabsMicrium’s µC/Probe and SEGGER’s SystemView can be invaluable for developers whose projects are based on the Micrium OS. The lab exercises described in this document will familiarize you with these two tools. The instructions for the lab assume that you have a Mighty Gecko Wireless Starter Kit (SLWSTK6000B), and that you’ve already insta lled µC/Probe and SystemView, as well as the Simplicity Studio IDE, on your PC. Download links for all of these tools are provided below.Download LinksSimplicity Studio: /products/development-tools/software/simplicity-studioThe Micrium OS example project prepared for these labs was developed using SimplicityStudio. You’ll need the IDE in ord er to build and run the project.µC/ProbeA visit to Micrium’s Web site to download µC/Probe is not necessary, since the tool was recently integrated into Simplicity Studio. However, you may need to use the IDE’s Package Manager to update your install and gain access to µC/Probe. Within the Package Manager, which you can find by clicking the button with the green, downward-facing arrow appearing near the upper-left corner of Simplicity Studio in the Launcher perspective, the link for installing µC/Probe is located on the Tools page, as indicated in the below screenshot. The Educational Edition of µC/Probe referenced by the link can be used without a license. If you’d like access to the full-featured Professional Edition of the tool, you can contact Micrium to get a one-year FAE license at no cost.SystemView: https:///downloads/free_tools/Setup_SystemView_V242.exe SystemView is a free tool from SEGGER. In order for the tool t o work properly, you’ll need the latest J-Link software, which is also available from SEGGER: https:///downloads/jlink/JLink_Windows_V614c.exe.Lab 1: Building and Running the Example ProjectIn this lab, you’ll build and run a Simplicity Studio example proj ect incorporating the Micrium OS. You’ll use this project in Lab 2 and Lab 3 to explore the features of µC/Probe and SystemView.Procedure:1.Your hardware platform for the labs is the Mighty Gecko Wireless Starter Kit. Youshould now connect one of your k it’s main boards (BRD4001A) to a radio board(BRD4161A). You should then establish a USB connection between your PC and thecombined boards. Your main board features a built-in J-Link debugger, and the USB connection will allow you to leverage this debugger within Simplicity Studio.2.If you’re not al ready running Simplicity Studio, you should start it now. You shouldmake sure that you’re in the Simplicity IDE perspective, which you can open by selecting Window>Perspective>Simplicity IDE.3.The example project for the labs is delivered in a zip file named Micrium-Tools-Lab.zip.You should now extract the contents of this zip file to a folder of your choice. To avoid any possible issues with long path names, it is recommended to keep the zip file contents relatively close to your root folder.4.You’ll now need to import the example project that was delivered in Micrium-Tools-Lab.zip. You should start the import process in Simplicity Studio by selecting File>Import…. On the dialog that subsequently appears, you should expand General and select Existing Projects into Workspace, as indicated in the below screenshot. You should then click the Next button.5.Within the second Import dialog, you should ensure that Select root directory is chosenand you should then click the corresponding Browse button. You must then navigate to the location of the project folder (named Tools-Lab-1) that was provided in Micrium-Tools-Lab.zip. Before clicking the Finish button, you should ensure that the Tools-Lab-1 is checked in the Projects field and that Copy projects into workspace is likewise checked, as indicated in the below screenshot.6.The example project should now appear in your Project Explorer, as indicated below.To clean any build artifacts that might exist for the project, you should right-click its name, Tools-Lab-1, and select Clean Project from the menu that appears. If the clean operation was successful, you should then attempt to build the project by again right-clicking the project name and this time selecting Build Project.7.The build operation for your project should have completed without any errors. (Thereshould have been one warning associated with deprecated interrupt code in the BSP.) In the case of a successful build, you should now attempt to download your project’s code to your board by right-clicking Tools-Lab-1in the Project Explorer and then selecting Debug As>1 Silicon Labs ARM Program.8.Simplicity Studio should automatically switch to the Debug perspective as a result ofyour actions in the previous step. Within this pers pective’s editor area, the tool should indicate that execution of your project is halted on the first line of the main() function. You should now start execution of the project’s code by clicking the Resume button shown below. LED0and LED1should then begin alternately blinking on yourboard.9.After confirming that your code is running and your LEDs are blinking, you can terminateyour debug session by right-clicking the Silicon Labs ARM MCU item that, as indicated inthe below screenshot, should appear in the Debug window. You should selectTerminate from the subsequent pop-up menu. Your LEDs should continue to blink afterthe debug session has ended, since your project’s code now resides in Flash memory.Lab 2: µC/ProbeIn this lab, you’ll use µC/Probe to visualize the internals of the project that you built in Lab 1. You’ll first monitor one of the project’s C variables, and you’ll then use µC/Probe’s kernel-awareness capabilities to view statistics output by the µC/OS 5 kernel on which the project is based.Procedure:1.You should now run µC/Probe. You can actually start the tool within Simplicity Studio byclicking the button shown in the below screenshot.2.µC/Probe makes it possible to view the values of an application’s variables as codeactually runs. In order to offer this capability, it needs information on the variables’ locations. It typically gets this information from an ELF file. When you built the Micrium OS example project following the procedure given in the previous section of this document, an ELF file, Tools-Lab-1.axf, should have been generated by Simplicity Studio and placed at the path listed below. In this path, <project_location> is the folder where your project resides. If you’re uncertain of this location, you should right-click the project’s name in Project Explorer and select Properties. If you then select Resource from the categories listed on the left side of the Properties dialog, you’ll be able to read your project folder from the Location field in the upper half of the dialog.<project_location>\GNU ARM v4.9.3 - Debug3.You can pass an ELF file to µC/Probe using the Symbol Browser located at the bottom ofthe tool’s main window. You should now click the Symbol Broswer’s ELF button, which is shown in the below screen shot. In the ensuing dialog, you should simply browse to the ELF file described above and then click the Open button.4.µC/Probe will be able to use your board’s built-in J-Link debugger to access variables inyour running example code. In order to establish J-Link as your preferred communication interface, you’ll need to select it in the Settings dialog. You should now open this dialog by clicking the Settings button shown below.5.As indicated in the below screenshot, the lower left corner of the Settings dialogcontains a list of Debug Interfaces containing just one item: J-Link. You should confirm that J-Link is selected, and you should then ensure that Don’t Change has been specified for the Interface Mode. Before clicking OK, you should choose Silicon Labs as the Manufacturer, and, using the provided table, select EFR32MG12PxxxF1024as your Device.6.µC/Probe provides a variety of graphical components that can be used for displaying thevalues of variables. You can access these components via the Toolbox located on the left side of the main program window. You should now instantiate a new component—a gauge—by first clicking Angular Gauges in the lower half of the Toolbox and thendragging and dropping the Semicircle 3gauge onto the data screen in the middle of µC/Probe’s program window. The data screen should then appear as shown in thebelow screenshot.7. A graphical component is not of much use until it has been associated with a variable, orsymbol. The Symbol Browser will be your means of associating a variable with your new gauge. If the Symbol Browser is not already displaying a list of C files corresponding to the code that you built in the first part of the lab, you can make such a list appear by expanding the entry for Tools-Lab-1.axf that appeared when you specified the path of this file in Step 2. Once the list is visible, you should expand the entry for the C file ex_main.c in order to make the variables contained in that file appear. You should then drag and drop the variable Ex_MainSpeed from the Symbol Browser to your gauge. As indicated below, the variable name will appear below thegauge to indicate that the two are associated.8.You should now click µC/Probe's Run button, which, as indicated below, is located in theupper left-hand corner of the tool's main program window. If you’re using the Educational Edition of the tool, you’ll be presented with a dialog indicating that you won’t have access to µC/Probe’s full set of features unless you upg rade to the Professional Edition. You can simply click this dialog’s Close button. You will then enter µC/Probe’s Run-Time mode. The dial on your gauge should begin moving from 0 to 100 and then back to 0. It should repeat this pattern indefinitely. Keep in mind that, with the Educational Edition, you will only be able to remain in Run-Time mode for one minute before a time-out occurs and another dialog prompting you to upgrade appears.9.µC/Probe can be used with nearly any embedded system—including those not based ona real-time kernel. However, the tool is especially helpful when paired with projectsthat incorporate Micrium’s embedded software modules, in part because of its kernel-awareness capabilities. These capabilities are implemented via a number of pre-populated data screens that show the values of different kernel variables. You should now stop µC/Probe (by clicking the Stop button located in the upper left-hand corner of the main program window) and add the kernel-awareness screens for µC/OS 5, the kernel featured in the example project, to your workspace. You can add the screens by first clicking Project1in µC/Probe's Workspace Explorer window and then clicking Screens>Micriµm OS Kernel (µC/OS-5), as indicated in the below screenshot. After making this change, you can again click Run to prompt µC/Probe to begin updating the new screens with kernel statistics.10. Within the main µC/OS 5 kernel-awareness screen, there are a number of subordinatescreens, including one for Task(s). As shown below, this screen displays the status of each task running in your project. You should now take a moment to look over the screen and familiarize yourself with the various tasks that the example incorporates.The percentage of CPU cycles consumed by the tasks is provided in the CPU Usage column, and you should note that, after the kernel’s Idle Task—which runs when no application tasks are ready—it is the Tick Task—the kernel task responsible for processing periodic tick interrupts—that consumes the most CPU cycles, with a usage of approximately 5.5%.11.After you’ve looked over Task(s), you should stop µC/Probe (via the Stop buttonmentioned in Step 9). You should then return to Simplicity Studio to make a simple change to the example project’s code. Within the IDE, you should open the file ex_main.c. You’ll be able to find this file by expanding the Micrium folder within the Project Explorer, and then similarly expanding Micrium_OS_V5.00 and examples. You should add the below two lines to ex_main.c, placing the new code at line 156, just below the variable declaration in the main() function. The result of your addition will be to change the frequency of tick interrupts received by the kernel, from 1 kHz to 100 Hz.OS_TASK_CFG Ex_MainCfgTick = {DEF_NULL, 256u, 4u, 100u};OS_ConfigureTickTask(&Ex_MainCfgTick);12.You should now build and run your modified project, following the same procedure thatyou used in Lab 1. Afterward, you should return to µC/Probe and again run your workspace. With tick interrupts now occurring at 1/10 of their original frequency, you should confirm that the overhead of the kernel’s Tick Task has experienced a similar decrease, meaning that the task’s CPU usage should be around 0.6%.Lab 3: SystemViewThis lab w ill walk you through the steps needed to use SEGGER’s SystemView with the example project featured in the previous two labs. With SystemView, you’ll be able to see the cont ext switches, interrupts, and kernel function calls that occur as the project runs.Procedure:1.Because the latest Micrium OS is a relatively new software module, it is not yetsupported by the version of SystemView available from the SEGGER Web site.Fortunately, though, it is fairly easy to update SystemView so that it will recognize applications based on MicriumOS. To make the update, you should now copy SYSVIEW_Micrium OS Kernel.txt, which was provided in Micrium-Tools-Lab.zip, and paste this file into the Description folder in the SystemView install path—Program Files (x86)\SEGGER\SystemView_V242.2.You should now run SystemView by clicking the tool’s entry in the Windows Start menu.3.When you run SystemView for the first time, you’ll be presented with the below dialog,asking whether you’d like to load a sample recording. You can simply click this dialog’s No button.4.In order to begin analyzing the behavior of your example project’s code, you’ll need torecord the code’s activity. To initiate recording, you should select Target>Start Recording within SystemView. You will then be presented with a Configuration dialog.Once you’ve verified that the contents of this dialog match the screenshot shown below, you should click the OK button to initiate recording.5.Shortly after you’ve started to record, you may be presented with the dia log shown inthe below screenshot. This dialog indicates that some of the data that would otherwise be displayed by SystemView was lost, because the buffer used to temporarily store that data on your target experienced overflows. You can simply click OK to close the dialog.For information on how to limit the potential for overflows, you can consult the last section in this document.6.Once you’ve gathered a few second’s worth of data, you should click the Stop Recordingbutton shown in the first of the two screenshots shown below. As the second screenshot indicates, the Timeline located near the center of the SystemView main program window should subsequently display all of the task and ISR activity that occurred during the period the recording was active. You now can begin investigating the execution of the example project’s code in detail.7.If you adjust the zoom on the timeline, you should be able to see, every 40 ms, thepattern of events depicted in the below screenshot. The example project incorporates three application tasks, in addition to a number of kernel, or system, tasks. One of the application’s tasks, labeled Post Task, peridocially performs a post operation on a semaphore, and that is what is shown in the screenshot. In the next couple of steps, you’ll adjust the period of the Post Task and then make an additional SystemViewrecording to confirm the results.8.The period of the Post Task is established by a variable in the same file that youmanipulated in Step 11 of the previous lab, ex_main.c. The variable is named Ex_MainDelayPostms and you have two different options for changing its value.One is to simply replace the variable’s initialization on line 371 of ex_main.c with thebelow code. You’l l then need to rebuild the example project and again download its code to your board. The second option involves µC/Probe. In addition to allowing you to read variables, µC/Probe offers a number of Writable Controls for changing variable values. You can drag and drop one of these controls—a Horizontal Slider, for example—into your workspace from Lab 2, and use the new control to adjust the value of ExMainDelayPostms.Ex_MainDelayPostms = 20;9.With the value of the variable adjusted, you should return to SystemView and make anew recording. Now the post operation described in Step 6 should be visible every 20 ms, as opposed to 40 ms. If time permits, you can make further adjustments to the code, changing, for example, the priority of the Post Task (established by the #define EX_MAIN_POST_TASK_PRIO), and you can use SystemView to observe the results of the changes.Limiting OverflowsThere are a few steps that you can take to limit overflows and maximize the amount of data recorded by SystemView. One of these is to increase the size of the buffer used to temporarily store SystemView data on your target before it is passed to the PC application. The buffer size is established by the #define SEGGER_SYSVIEW_RTT_BUFFER_SIZE in the file SEGGER_SYSVIEW_Conf.h. This file is contained in Micrium/Tools/SystemView/Config within the example project. The provided copy of SEGGER_SYSVIEW_Conf.h uses a buffer size of 4096, but you’re free to increase to any size that the hardware can accomodate.An additional measure, recommended by SEGGER for reducing the number of overflows, is to ensure that SystemView is the only tool using your J-Link. In other words, if you were previously running µC/Probe or the Simplicity Studio debugger while recording data, you should stop the other tools and try a new recording. With exclusive access to the J-Link, SystemView should have fewer impediments to capturing all of the example project’s events.。