Sensor Controller Studio Hands-On Introduction This introduction lab is the entry level guide on how to use sensor controller studio to generate and debug code that will run on the sensor controller processor. After the hands-on tasks there is a note describing how to add a sensor controller task to an application project. Please note that the latest installer (Version 1.0.1 (June-2015)) currently only support the XDS100 debugger. Support for the XDS110 ( JTAG device in ST DevPack) will be added in the next release (version 1.1). Pre-requisites Knowledge: - Basic familiarity with IDEs (IAR or CCS) Software - IAR Embedded Workbench (version 7.30.4 or later) or Code Composer Studio (version 6.1 or later). Hardware - 1 x CC2650EM (Evaluation Module) - 1 x SmartRF06 Evaluation Board - 1 Micro-USB cable Task 1 Getting started Making sure it works - Make sure IAR Embedded Workbench or CCS is installed. - Download SCS and install it to default location. http://www.ti.com/tool/sensor-controller-studio Task 2 Run the Analog Light Sensor example This task is almost the same exercise as the Tutorial: Analog Light Sensor which can be found in the SCS Quick Start Guide. The quick start guide has more detailed information than this task. A link to the document is given in the Tool Documentation Pane which resides on the top tight of the start page in SCS. The quick start guide resides in the path given below. C:\Program Files (x86)\texas Instruments\Sensor Controller Studio\docs
Task 2.1 Moving On - Open SCS. - Start the example either by double clicking on the given example as shown below or by pressing file- > Open Project and selecting: \Documents\Texas Instruments\Sensor Controller Studio\examples\analog_light_sensor\analog_light_sensor.scp Double click on the Analog Light Sensor Example - In the Projects settings set Operating system to TI-RTOS. - Review the task code (Initialization -, Execution - and Termination code). Quiz: a. How many times will the Initialization code run? b. How often will the Execution code run? Hint: see help text on the fwscheduletask prodecure - Go to the Code Generator tab by navigating there in the left panel or by using the keyboard combination CTRL+G. - Verify that your project is selected in the Current Project Selection (If this is the only open project it will be selected by default). - Push the bottom button called Generate driver source code. If there are no compile errors your source code will be compiled into assembler and the driver source code will be generated. In the figure below you can see an overview of the Code Generator panel.
Memory Usage Generate driver source code Generated SCIF driver files Task 2.1 Run example on the (CC2650EM or CC1350EM)+SmartRF06EB - Open your IDE (IAR or CCS) - Open the TI-RTOS version of the standalone example code found here: Documents\Texas Instruments\Sensor Controller Studio\examples\analog_light_sensor\projects\iar_tirtos\analog_light_sensor_tirtos.eww Documents\Texas Instruments\Sensor Controller Studio\examples\analog_light_sensor\projects\ccs_tirto\analog_light_sensor_tirtos.projectspec - Connect a USB cable to your SmartRF06EB + EM and power the board. - Compile and download the project to your device. - Verify that the example runs as expected by covering the light sensor on the EB with your hand (then all LEDs should be shut off). Task 2.2 Task Debugging In this task you will debug the sensor controller task (analog light sensor). - Go to the Task Testing panel by navigating there in the left pane or by using the keyboard combination CTRL+T. - Verify that your project is selected in the Current Project Selection (If this is the only open project it will be selected by default). - Push the bottom button called Generate and output task testing driver source code.
- Open the task_testing project in IAR or CCS and download the code to your CC2650 device. The project is located here: Documents\Texas Instruments\Sensor Controller Studio\examples\task_testing\projects\iar\task_testing.eww Documents\Texas Instruments\Sensor Controller Studio\examples\task_testing\projects\ccs\task_testing.projectspec - Start a debug session in SCS by pressing the Connect button ( ) or F12. - Skip the initialization code by pressing the Run the initialization code once button ( ) or F6. - Then enter debug of execution code by pressing the Execution code debugging button ( ) or CTRL+F11. - Go to the assembler code line where the ADC is disabled and set a break point by pressing F9 while the line is marked. Then run the code by pressing F5 and wait until the breakpoint is triggered. - Observe the state.adcvalue and remember it. Then hold your finger over the light sensor and repeat the code execution by pressing: o F5 Run continuously o F8 End the debug session o F6 Run the termination code once o F6 Run the initialization code once o CTRL+F11 Run the execution code once in the task debugging panel o F5 Run continuously Then verify that the value is lower due to less light hitting the sensor. Unfortunately it is not possible to simply restart the execution code without going through the steps mentioned above (SCS version 1.0.1). - Play around in debug mode if desired. Note: When you do significant changes to the projects such as change IO mapping, alter RAM variables (cfg.x, state.x, input.x, output.x), etc. you will need to generate task testing drivers again and download the "Task Testing" project from IAR/CCS to your device before you start a new debug session from Sensor Controller Studio (SCS) (You can then see changes in the content of sciftestdriversetup in the generated files). If you do small logic changes to the execution code (simple changes to pauxramimage) you do not need to download the "Task Testing" project again. Then you can simply start a new debug session from SCS (the new pauxramimage will be loaded). Task 2.3 Run Pre-execution data vectors In this sub-task you will observe the data structures in real time while the sensor controller program is running. - Connect to your device by pressing the Connect button ( ) or F12. - In the right pane tick off cfg.pbinthresholds, output.bin and state.adcvalue. - Press F6 to run the initialization code once and then press F5 to run (free) the code. Provide different levels of strength to the light sensor and observe the value in state.adcvalue.
Now you will load a Pre-Execution Vector Input file to illustrate how you can set a predefined list of values that will be automatically loaded into the cfg.pbinthresholds array. - Create a.csv file with the content found in Appendix B CFG Input Indexed. (You can use excel to create this file). - Load the file you created above by using the Task Testing menu or pressing the open file button ( ) on the right. Then press F6 to run the initialization code once and then press play. Observe the changes. Try to interpret the behavior.
Note: How to integrate SCS drivers into an Application It is fairly easy to integrate a sensor controller application with your main application project. To do this you must simply generate the sensor controller drivers and copy the following files to your main application project (TI-RTOS based): o scif.c o scif.h o scif_framework.c o scif_framework.h o scif_osal_tirtos.c (scif_osal_none.c when running standalone (no operating system)) o scif_osal_tirtos.h (scif_osal_none.h when running standalone (no operating system)) For fast access to the files, push the button on the bottom right in the Code Generator pane to view the output directory which contains the files mentioned in the list above. Then you will need to merge content from main_tirtos.c or main.c from the examples that come with SCS into your application main file to initialize and set up the required configuration for the sensor controller task.
Appendix A Answers to Quiz a. How many times will the Initialization code run? It will run once for every time scifstarttasksnbl is called. PS: This function must not be called for already active tasks. b. How often will the Execution code run? It depends on the task tick interval. For the analog Light Sensor example it is set to the following: // Set the Sensor Controller task tick interval to 1/8 second scifstartrtcticks(0x00010000, 0x00002000); In the execution code the next execution code run is scheduled to start at 1 task tick later (1/8 of a second): fwscheduletask(1); Appendix B CFG Input Indexed index;cfg.pbinthresholds.[0];cfg.pbinthresholds.[1];cfg.pbinthresholds.[2];cfg.pbinthresholds.[3];cfg.p BinThresholds.[4];cfg.pBinThresholds.[5] 0;800;800;800;800;800;800 20;100;800;800;800;800;800 40;100;200;800;800;800;800 60;100;200;300;800;800;800 80;100;200;300;400;800;800 100;100;200;300;400;500;800 120;100;200;300;400;500;600
Appendix C How to connect to SensorTag to the SmartRF06EB Debugger (XDS100) The setup is shown in the figure below. A 10-pin 1.27 mm pitch debug cable is used to connect the P410 header on the SmartRF06EB to the debug connector on the ST2.0. Figure 1 - CC2650 SensorTag2.0 connected to the XDS100 debugger on the SmartRF06EB.