Home
Using SYS/BIOS with Stellaris® ARM® Cortex
Contents
1. 1 Launch CCS from Start gt All Programs gt Texas Instruments gt Code Composer Studio v4 2 x gt Code Composer Studio v4 2 Make sure that the C C perspective is selected in CCS F Debug Fey C C 3 Select File gt New gt CCS Project amp C C Code Composer Studio Licensed mim Edit View Navigate Project Target Tools Scripts Window Help New File Standard Make Project Open File C4 Folder Di Source File Cii Header File File SF Class ET Target Configuration File a DSP BIOS v5 x Configuration File RTSC Configuration File F Other Refresh F5 Convert Line Delimiters To d 4 Type a name for the project in the Project name field Sf New CCS Project CCS Project Create a new CCS Project Project name Stellaris Example Use default location Location C Documents and Settings a0271819 My Documents SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 23 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com 5 Click Next Confirm that the ARM option is selected in the Project Type drop down menu New CCS Project Select a type of project Select the platform and configurations you wish to deploy on Project Type ARM Configurations ew e8neue SSS we Debug Select All tH Release
2. Submit Documentation Feedback Copyright BIOS Clock dock_iHz Defaults Diags Error Hwi Log LoggerBuf logger Main Memory Frogram Semaphore Swi sysMin System New Task Stop Using Task Help Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 2012 Texas Instruments Incorporated Creating a Sample SYS BIOS Project l 14 Edit the fields of the new task instance as shown Click OK S Create new Task Params Name Value name task_low_freq Create Args fxn toggle _low_freg Params arg argi priority stack stackSize stackSection stackHeap env vitalTaskFlag Summary Name of the instance Task Function Task function argument Default is 0 Task function argument Default is 0 Task priority 0 to numPriorities 1 or Task stack pointer Default null Task stack size in MALs Mem section used for statically crea Mem heap used for dynamically cre Environment data struct TEXAS INSTRUMENTS www ti com Exit system immediately when the i Cancel 15 Add a second task instance by following the same method Click OK amp Create new Task Params Name Value name task_low_freg Create Args fxn toggle _low freq Params arg argi priority stack stackSize stackSection stackHeap env vitalTaskFlag 28 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Summary Name of the instance Task Function Task fun
3. Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated ld TEXAS INSTRUMENTS www ti com Overview of SYS BIOS 2 8 Debugging Tools The process of debugging a real time system requires additional real time analysis tools because of the latency that is introduced into the system with a traditional debugger SYS BIOS provides several tools and features including e Asserts e Logging in application and RTOS e Real time analysis Asserts check for common user mistakes such as calling an API with an invalid argument or from an unsupported context Logging prints important events in both the application and the RTOS to a terminal for debugging timing issues in a system Real time analysis streams debugging data to the host without stopping the processor An important feature to note about the SYS BIOS debugging tools is that the log and trace information is formatted on the host computer so that the application processor can continue to execute code with minimal to no interference To access the SYS BIOS real time analysis RTA tools make sure CCS is in the debug perspective Then navigate to the Tools gt RTA menu option to see the available RTA tools Figure 17 displays the available RTA tools eer scripts Window Help Memory Map EY 2 a dh Fe GEL Files On Chip Flash Die EEA ARM Advanced Features Debugger Options j Port Connect Fin Connect RTSC Tools j Profile j ROV M RTA
4. Deselect All Show All Project Types Show All Configurations 6 Click Next In this case there will not be any referenced projects so leave all project boxes unchecked if any appear in the Referenced Projects field amp New CCS Project Additional Project Settings Define the inter project dependencies if any i Projects C C Indexer Referenced Projects Cancel 24 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated ld TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 7 Click Next Select Cortex M from the left Device Variant drop down menu Select the Stellaris device you are using from the drop down menu to the right of the Cortex M selection New CCS Project Project Settings Select the project settings Output type Executable Project settings Device Variant Cortex mM s Stellaris LM359696 Ww Device Endianness litte Code Generation tools EE v4 9 0 ka More output Format leabi ELF we Linker Command File lt automatic gt a Ca Cc 8 Click Next Under the SYS BIOS folder select the new project type you would like to use minimal typical or typical with a separate config project These options are explained earlier in this section see Section 5 Creating a Sample SYS BIOS Project
5. The template opens with a single task function consisting of several printf statements and a call to the Task_sleep function The typical template is a common starting place for most SYS BIOS applications Unlike the minimal template the typical template enables dynamic memory allocation which allows tasks to be created at runtime instead of statically defined at compile time In fact the example project opens with a call to the Task_create function in order to define the single default task The typical template with a separate configuration template creates a typical project in addition to a second project that contains the configuration file for the first project Multiple projects can now reference the single configuration project for their SYS BIOS settings thereby reducing build times and allowing several developers to use a uniform configuration For the purpose of the example project listed below the Stellaris DK LM3S9B96 development board is used However any of the Stellaris Cortex M3 devices can be substituted and used as the platform for this example Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 5 1 Creating a New Project This section describes how to load a project template into the workspace
6. cg Basic Options Advanced Options E Search libraries in priority order priority priority Restore Defaults Apply 5 Type C StellarisWare driverlib ccs cm3 Debug driverlib cm3 lib into the File field in the Add file path dialog box Add file path File C Stellaris Ware driverlib ocs cm 3 Debug driverlib cm3 lib 6 Click OK in the Properties window 34 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 7 Inthe main c file add the following include statements to the top of the code include inc hw_types h include driverlib sysct Leh include lt xdc etd h gt cry include lt xdc runtime Error h gt inelude lt xdc runtime System h gt Li lo include lt ti sysbios BI05 h gt include lt ti sysbios knl1 Task h gt tai Pa i j fs 14 include inc hw types h include driverlib sysctl n 5 3 Building and Debugging a Project This section outlines the steps required to build a project and launch the project in the debugger This section also highlights several of the key SYS BIOS diagnostic tools 1 Build the project by right clicking the project and selecting Rebuild Project C C Projects X EE Stell
7. processors wiki ti com contains the following SYS BIOS resources e SYS BIOS Overview e SYS BIOS Getting Started Guide e SYS BIOS Online Training e SYS BIOS for Stellaris Devices e SYS BIOS Getting Started Workshop Additional resources are available on the web e SYS BIOS E2E Forum e Stellaris Sizing Benchmark e Stellaris Timing Benchmark SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 41 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries TI reserve the right to make corrections enhancements improvements and other changes to its semiconductor products and services per JESD46 latest issue and to discontinue any product or service per JESD48 latest issue Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and complete All semiconductor products also referred to herein as components are sold subject to Tl s terms and conditions of sale supplied at the time of order acknowledgment Tl warrants performance of its components to the specifications applicable at the time of sale in accordance with the warranty in Tl s terms and conditions of sale of semiconductor products Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty
8. 17 Real lime Analysis TOONS cinciscisunsecwaswewdnsdncamaturteen aa a e a ia 15 Code Composer Studio is a trademark of Texas Instruments Stellaris StellarisWare are registered trademarks of Texas Instruments Cortex is a trademark of ARM Limited ARM is a registered trademark of ARM Limited All other trademarks are the property of their respective owners SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 1 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Introduction www ti com 1 2 1 Introduction SYS BIOS is a real time operating system RTOS kernel created by Texas Instruments TI that is intended to be used in embedded applications on a variety of the Tl microprocessors and microcontrollers including the Stellaris Cortex M3 family of devices Several key benefits of the SYS BIOS RTOS include e Scheduling e Pre emptive deterministic multi tasking e Configuration tools e Memory management e Hardware abstraction for cross platform applications SYS BIOS is included in the installation of Code Composer Studio CCS so creating a new project is fairly straightforward The configuration of the kernel is abstracted from the hardware by the SYS BIOS configuration tool called XGConf which is based on the open source XDCTools This tool is a graphical user interface GUI that allows for quick and easy manip
9. Choose Typical for this example project amp New CCS Project Project Templates Select one of the available project templates Empty Projects This example has a chg populated with a typical set of options and parameters This ctg file is a good starting point for many applications IPC and I O Examples Dyanamic memory allocation and runtime create SYS BIOS of is supported Unlike the Minimal example the single task is created at runtime using the Task_create API Basic Examples D H E E P Minimal 3 Typical P Typical with separate config project 42 Generic Examples SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 25 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated Creating a Sample SYS BIOS Project 9 Click Next Select the appropriate platform from the Platform Sf New CCS Project RTSC Configuration Settings Select the RTSC Configuration project settings xDCtools version 3 22 1 21 Products and Repositories g Order g BA Inter processor Communication fT get 1 23 2 27 S F SYS B105 fi af 6 32 2 39 el BA XDAIS J 7 10 0 06 I TEXAS INSTRUMENTS www ti com drop down menu ae More Ad Select All Deselect All Target ti targets arm elf M3 Platform
10. Cic 10 Go to Tools gt ROV to open the Runtime Object Viewer This tool provides information about the SYS BIOS modules when the target is halted term Scipts Window Help Memory Map GEL Files On Chip Flash ARM Advanced Features Debugger Options j Port Connect Pin Connect RTSC Tools H Profile a ROV it RTA XDAIS Tools Trace Control Trace Analyzer Graph g Image Analyzer SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 37 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated Creating a Sample SYS BIOS Project 38 11 Set a breakpoint in each of the tasks as shown 27T2Void toggle low freq 13 TEXAS INSTRUMENTS www ti com 28 293 while i i 30 Log intoO toggle low freq enter 32 Pend on the semaphore 33 Log infol toggle low fregi pend sem 34 Semaphore pend sem BIOS WAIT FOREVER 36 Set the value of the GPIO pin low 37 Log_info0 toggle_low_freq pin low 38 GPIO PORTA DATA R amp GPIO PIN 6 40 5leep 41 Lag infol toggle low fregi sleep 42 Task sleep i10 44 Post to the semaphore 45 Lag infoO toggle low freq post sem 46 Semaphore post sem 48 5leep 49 Log infol toggle low fregi sleep 50 Task sleep i0 52 Log_info0 toggle_low_freq exit 53 54 s65 Void toggle high freq 58 while 1 a 59 Log_info0 toggle high freq en
11. Except where mandated by applicable law testing of all parameters of each component is not necessarily performed Tl assumes no liability for applications assistance or the design of Buyers products Buyers are responsible for their products and applications using TI components To minimize the risks associated with Buyers products and applications Buyers should provide adequate design and operating safeguards TI does not warrant or represent that any license either express or implied is granted under any patent right copyright mask work right or other intellectual property right relating to any combination machine or process in which Tl components or services are used Information published by TI regarding third party products or services does not constitute a license to use such products or services or a warranty or endorsement thereof Use of such information may require a license from a third party under the patents or other intellectual property of the third party or a license from TI under the patents or other intellectual property of TI Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties conditions limitations and notices TI is not responsible or liable for such altered documentation Information of third parties may be subject to additional restrictions Resale of TI components or ser
12. History Tool chain Settings B TMS470 Compiler 83 Basic Options g amp Symbolic Debug Options 83 Language Options 83 Parser Preprocessing Options Predefined Symbols 3 Include Options g amp Diagnostic Options 3 Runtime Model Options 3 Optimizations 3 Entry Exit Hook Options Library Function Assumptions amp Assembler Options 33 File Type Specifier 3 Directory Specifier Default File Extensions g amp Command Files G3 MISRA C 2004 MISRA Rules TMS470 Linker amp Basic Options g amp Command File Preprocessing g Diagnostics File Search Path Linker Output 83 Symbol Management 3 Runtime Environment g amp Linktime Optimization 83 Miscellaneous g amp Dynamic Linking Support Options E xDctools 2 Package Repositories 3 Basic Options 83 Advanced Options Specify a preinclude file preinclude Add dir to include search path include_path I CG TOOL ROO dude Restore Defaults Apply Workspace Cancel field in the Add directory path dialog box Click OK File system SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Copyright 2012 Texas Instruments Incorporated 33 ld TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com 4 Click the File Search Path folder under the TMS470 Linker folder in the folder t
13. M3 Microcontrollers 21 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com Ze 9 Click Next Make sure that the SYS BIOS box is checked in the main window Also select the appropriate platform from the Platform drop down menu New CCS Project Select the RTSC Configuration project settings GE ape ee ee ep BA Products and Repositories Pap Order fl BA Grace M5P4305 Pat 1 0 1 83 G p Inter processor Communication ci BA SYS BIOS fi 6 32 2 39 ey n a RTSC Configuration Settings al Hiss Select All MDCtools version 3 22 1 21 More Deselect All Target Platform Build profile 10 Click Finish 11 After the project is loaded the project can be built and debugged See Section 5 3 Building and Debugging a Project The log example showcases the features of the Raw Logs and Printf Logs Real Time Analysis RTA Tools See Section 2 8 Debugging Tools Creating a Sample SYS BIOS Project Creating a new SYS BIOS project is easily done with the use of the provided project templates There are three types of templates e Minimal e Typical e Typical with a separate configuration project The minimal template is used for applications that use only statically defined objects Dynamic memory allocation is disabled to improve the code size and performance of the system
14. Text Stop Using Task Stop Using Task Help Rlockable Threads P Figure 4 Creating New Module Instances Double clicking the shaded box or clicking the item in the outline opens a window with the available options for the module 4 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Overview of SYS BIOS Figure 5 shows the options window that appears when the task module is selected This window controls the global task options The options for individual tasks are modified by clicking the specific task in the outline SYS BIOS Defaults amp Task Thread Managment The Task module allows you to create one or more prioritized threads each with a separate stack that can block on one or more events Add Task threads to my configuration Global Task Options Default Task Options Number of priorities 16 Default stack size 2048 All blocked function s knl Task allBlockedFunction Default stack section bss taskStackSection Initialize stack Check for task stack overflow C Delete terminated tasks Idle Task Options Options Enable Idle Task _ Idle Task is vital Default stack heap null Idle Task stack size 2048 Idle Task stack section bss task
15. User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Semaphores are used to protect resources that must complete a required operation within one task before switching control to another task There are two types of semaphores in SYS BIOS e Binary semaphores e Counting semaphores SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 11 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com Binary semaphores are typically used for resources that are either in use or available Counting semaphores allow a resource to be accessed by multiple tasks before restricting access to the resource A count of zero is the lowest possible value for a semaphore and indicates that the resource is not available Posting to a semaphore increments its count while pending on a semaphore decrements its count Calling semaphore_post mySem on a semaphore mySem with a count of one results in e A count of 2 on a counting semaphore e A count of 1 on a binary semaphore The following examples and figures show the operation of semaphores If a task is running and calls the Semaphore_pend function that is decrements the count of the semaphore on a semaphore with a count of 2 the task continues to run as show in Figure 13 myTask myTask Sem
16. allows the application to take advantage of the minimal interrupt latency built into the core but the latency is not the default configuration of the SYS BIOS kernel The Zero Latency Interrupt feature of the SYS BIOS system bypasses the SYS BIOS interrupt dispatcher and therefore prohibits ISRs from using the SYS BIOS services and APIs Additional information about incorporating this type of interrupt structure can be found on the SYS BIOS for Stellaris Devices Wiki page Find more detailed information about hardware interrupts in the SYS BIOS API Reference in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Software Interrupts Hardware interrupts are often used to service time sensitive resources However once these data have been collected the data can be passed to a less restrictive thread for further processing In SYS BIOS software interrupts SWIs are often used to process hardware interrupt data They are preemptive and generally have a priority between 0 15 SWIs operate from a single stack which reduces the memory size of the overall application but prevents SWls from blocking on semaphores suspending themselves using a sleep function or terminating themselves using an exit function The size of the stack required for the SWIs is directly proportional to the number of priority levels that the system needs The saving and restoring of the SWI context is automatically hand
17. function is re entrant Arguments to the function can be used to determine which task called the function The life cycle of a task consists of four states e Ready a task is ready to be executed Ifa task is statically created at startup the task enters this state lfatask is dynamically created during runtime using the task_create API the task enters this state The highest priority task that is ready to run is moved from the ready state to the running state Ifa task in the ready state calls the task_delete function the task is moved to the terminated state e Running a task is the highest priority task ready to run Ifa higher priority task preempts this task the scheduler puts the task back into the ready state Ifa task is running and is then blocked by a semaphore_pend API call because the task is waiting for a resource of event the status is changed to blocked lf the running task calls the task_yield function the task is moved to the ready state lf the task call the task_exit function the task is moved to the terminated state e Blocked a task is waiting for a resource or event and posted a semaphore_pend API call lf asemaphore_post call is made the task is moved back to the ready state e Terminated a task has completed execution A task should not be terminated when the task is in the blocked state to ensure that program resources are properly released before the task i
18. mmmn m m SYS BIOS Defaults XDC Diags XDC Log Hwi Task tsk0 Source Figure 6 Text Based Editor Copyright 2012 Texas Instruments Incorporated Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 5 I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com 2 2 2 3 The text based editor can be opened outside of the GUI editor by right clicking the cfg file in the project and selecting either Open With gt XDCScript Editor or Open With gt Text Editor A detailed description of the available parameters is found in the API Reference in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Threads and Priority Levels Within SYS BIOS the term thread refers to a set of instructions that can be executed by the CPU after the required registers have been properly initialized The four types of threads available in SYS BIOS are e Hardware interrupt HWI e Software interrupt SWI e Task e Idle There are two types of priority levels in a SYS BIOS system e Implicit priority levels defined by thread type e Explicit priority levels defined by the programmer The implicit priority levels for the four main thread types are shown in Figure 7 Software Interrupt Task Lowest Priority Idle Figure 7 Implicit Thread Priority Levels Hardware interrupts have the highest implicit priority level in the system followed by software interrupts tasks an
19. of the samples for example sample 9 The processing of this data takes longer than the time between samples Using this configuration the HWI is able to retrieve the new data while the SWI continues to process the previous sample As soon as both the HWI and SWI are finished processing the Idle thread regains control of the system SWIs of the same priority are processed in a first in first out FIFO type system Figure 11 shows an instance where this may occur and how the interrupts are processed Swi_post amp Swi_b Highest Priority HWI Swi_b p1 Swi_a p1 Legend IDL LPM Running Lowest Priory L t time gt Figure 11 Same Priority SWIs Swi_a and Swi_b are both set to the same priority level of 1 A HWI preempts the execution of Swi_a and during its process posts a call to Swi_b Since the SWls are of equal priorities Swi_a must complete executing its instructions before Swi_b can begin executing As soon as both of the SWls are done executing program control is returned to the Idle thread Although SWIs only run once regardless of the number of times the SWIs were posted prior to execution you can also determine how many times a SWI was posted The Swi_inc function returns the number of times the SWI was posted before the SWI ran You can also schedule a SWI after the SWI has been called multiple times The Swi_dec function requires that the SWI is posted an explicit number of times before the SW
20. ti platforms stellaris LM3S9896 Build profile 1 elease 10 Click Finish 11 Since we are using the StellarisWare library to access the GPIO peripheral you must add driverlib to the project by following the steps provided in Section 5 Creating a Sample SYS BIOS Project 12 To begin editing the properties of the program expand the project folder right click the app cfg file and select Open With gt XGCONF The main GUI editor opens From here the settings of the SYS BIOS kernel can be modified See Section 2 1 Configuration Tools for more information about configuring the system 26 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated l TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com Sf C C Code Composer Studio Licensed File Edit View Navigate Project Target Tools Scripts Window Help 3 y a a ys i re a G r i Q oe i ae f Yi E alfa C I es Eo 1 lle gt Stellaris_ Example Active Debug Fs Includes ic main ARE new C Projects X d rl m3s9b9 E makefile Open i Open With F Active Build Configuration Exclude File s from Build copy Ha Paste I Delete In Place Editor Default Editor SPMA040A January 2012 Revised November 2012
21. to be ported between the various product families with little to no modification required This overview is based on SYS BIOS version 6 32 02 39 Different versions of SYS BIOS may contain slightly different features Configuration Tools The configuration of the SYS BIOS kernel is saved in the cfg file in the project This file defines the basic parameters for modules used in the system as well as any statically defined instances of modules The configuration file can be modified using one of two methods e Graphically using the XGCONF configuration utility e Textually using the XDCScript editor or other text editor After a project is loaded into CCS open the cfg file by right clicking the file in the project and selecting Open with gt XGCONF as shown in Figure 1 For instructions on opening a SYS BIOS project in CCS see Section 4 Running an Existing SYS BIOS Project Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Overview of SYS BIOS amp C C Code Composer Studio Licensed File Edit View Navigate Project Target Tools Scri Window Help A Ta p E Be s Q A Hic C C Projects X Se Stellaris_Example Active Debug a Includes E e main c ES New gt L m3s9b9 makefile Open Open With a Text E
22. 20 Save the project using File gt Save All from the menu GPIO_PIN_6 SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Copyright 2012 Texas Instruments Incorporated 31 Creating a Sample SYS BIOS Project 5 2 32 Integrating StellarisWare Libraries I TEXAS INSTRUMENTS www ti com StellarisWare is a software package provided for use with Stellaris microcontrollers that enables the use of API functions located in the read only memory ROM of most Stellaris devices Note that not all StellarisWare functions are inherently thread safe In other words having a higher priority task call a function after the first task has started executing the function may cause unexpected failures in the system To remedy these types of situations those functions that are not thread safe and are called from more than one context should be protected with the use of semaphores or gates The following steps outline the process of linking the driverlib API library into a SYS BIOS project The process should be repeated to incorporate the usblib USB and grlib graphics libraries If your project does not include calls to the StellarisWare libraries you can skip this section and go to Section 5 3 Building and Debugging a Project 1 Right click the name of your project and select Build Properties fH gt Binaries al iS In
23. 41 List of Figures 1 DEMING e A F e erR E E a 3 2 Configuration Tool OvervieW cc cece cece cece eee eee ees 3 3 Adamo and Pe moving MOOUICS ccanudtenvencaystiwerscudsadciveesew ere caste cemoosusssanexeunasmwacsaremeneees canes 4 4 Creating New Mod le INStaNCES s cccaesinesatcorenegnseseuitanrsesuane en sut unease ieren n rE i 4 5 Edit MOOUIG QDNONGS eancecse ede trapeccascresae aecueioescecce new E 5 6 TECE ase ENO estes oo ae esse ie cae Se ces ee est sc ete eso tiene eee seeee Steere cea reese ete uece 5 7 implicit Thread Prhonty Levels sssesrsnnn irens E I EEE 6 8 Foreground and Background Scheduling cccce cece eee eee eee nen eee ene eee 7 9 Hardware Versus Software IMienUpiS e cicersceccesectaiedwenesesteceeeidaexeeseconseseeeeditentessaverexeaeseseenecaxdwe 8 10 FIV and So VVI EX aI Cao csccuescesceuscecosnennseveseesspavass EEE EREET i 9 11 SWE MOMMY VIG ecto e wis eajetee ooses sree steele ucires E E E E ates 9 12 Task Slate DigOi EE EE eased cae ace ee esta ee tae cease meus aeaesaeeeect EE E 11 13 Task Continues to Run After Semaphore_Pend a assnsnsnunnsnnnnnnnnnnnnnnnnennrnnnennrnnnnnnnnenennrnennnnne 12 14 Blocking a Task With a SQMADNOSE ec ccc ec cece cece eee eee ene een eee 12 15 Unblocking a Task With a Semaphore cccecccecndecesdcenensesewsdacsocedeexaeeSuececdnite secenderessteeedecadewesscees 13 16 Unblocking a Task With a Semaphore When Multiple Tasks Are Blocked nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 13
24. ENTS www ti com SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project Post to the semaphore Log_info0 toggle_low_freq post sem Semaphore_post sem Sleep Log_info0 toggle_low_freq sleep Task_sleep 10 Log_info0 toggle_low_freq exit Void toggle_high_freq while 1 Log_info0 toggle_high_freq enter Pend on the semaphore Log_info0 toggle_high_freq pend sem Semaphore_pend sem BIOS_WAIT_FOREVER Set the value of the GPIO pin low Log_info0 toggle_high_fregq pin low GPIOPinWrite GPIO_PORTA BASE GPIO_PIN_6 Sleep Log_info0 toggle_high_freq sleep Task_sleep 1 Set the value of the GPIO pin high Log_info0 toggle_high_freg pin high GPIOPinWrite GPIO_PORTA_ BASE GPIO_PIN_6 Post to the semaphore Log_info0 toggle_high_freq post sem Semaphore_post sem Sleep Log_info0 toggle_high_freq sleep Task_sleep 1 Log_info0 toggle_high_freq exit Void main Log_info0 enter main Enable and configure the GPIO peripheral SysCtlPeripheralEnable SYSCTL_PERIPH_GPIOA GPIOPinTypeGPIOOutput GPIO_PORTA_BASE GPIO_PIN_6 Initialize GPIO pin PA6 to a value of 0 GPIOPinWrite GPIO_PORTA_BASE GPIO_PIN_6 0 Start the BIOS scheduler BIOS_start enable interrupts and start SYS BIOS
25. I is scheduled These and other functions are explained in further detail in the SYS BIOS API Reference in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 9 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com 2 5 10 Find more detailed information about software interrupts in the Software Interrupt Run Time API in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Tasks The third SYS BIOS thread type is a task Unlike hardware and software interrupts tasks can block and allow other tasks to execute This requires that each instance of a task has its own stack in memory as opposed to the common stack model that is used by SWIs and HWls Therefore tasks are more memory intensive than other thread types Tasks can preempt and be preempted based on their priority which can be changed dynamically When tasks must wait for an event to occur or a resource to become available they block themselves using some type of synchronization module such as a semaphore Creating a new task in SYS BIOS can be done one of two ways e Statically at compile time e Dynamically during runtime Two tasks can point to a single function as long as the
26. StackSection XDC Diags XDC Log Hwi Task 52 Source Figure 5 Edit Module Options In addition to the graphical configuration utility a text based editor can be used to configure the RTOS At the bottom of the window shown in Figure 5 is a Source tab This tab displays the text version of the configuration file When a module is selected the relevant code is highlighted as shown in Figure 6 Clicking an item in the outline changes the sections of code that are highlighted SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback b Create the required tasks 27var tskParams new Task Params 2S9tskParams argO i 0tskParams argi 2 ci tskParams priority i tskParams instance name tsk0 I2tskParams vitaitTaskFiacg false osProgram global tsko Teask create tskOFxn tskParams 35tskParams new Task Params 96tskParams instance name tski 7tskParams argO ii 9 tskParams argi 12 o9tskParams priority i 2 tskParams vitaliTaskFliag false 51 Program global tski Task create tskifFxn tskParams J5tskParams new Task Params J4tskParams instance name tsk2 J5tskParams argO 2i J6tskParams argi 22 o7tskParams priority i 22 tskParams vitalTaskFlag false 1 O09Program gliobal tsk2 Task create itsk2Fxn tskParams the whole system oggerBuf Params ii5var logger Logg CMR Smee Tew
27. TOS typically have a low priority infinite while loop that is interrupted by a high priority interrupt service routine ISR This type of system allows for two priority levels in a foreground and background scheduling system This configuration is not easily scalable and is often insufficient for complex systems that require multiple priority levels A SYS BIOS based system introduces threading services that allow for these multiple priority levels and deterministic scheduling Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Overview of SYS BIOS Figure 8 shows the relationship between a typical program and a program based on the SYS BIOS RTOS init BIOS_start while 1 non real time Idle loop Loop with non real time work Hwi ISR get buffer get buffer process it process it printf Log_print0 j BIOS Scheduler Figure 8 Foreground and Background Scheduling The Idle loop runs as the lowest priority and is typically used for activating low power modes built in self tests BISTs and user interface code This loop is preempted by higher priority threads and resumes execution at the point where the loop was preempted as soon as the higher priority code completes execution The hardware interrupt HWI replaces the functionality of th
28. YS BIOS Wiki Download the latest version of CCS from the Texas Instruments Embedded Processors Wiki Note that the code size limited version of CCS does not include SYS BIOS so you must download the full DVD versions For the purpose of this document CCS version 4 2 4 00033 was used Different versions of CCS can be used but may contain slightly different features To download and install Code Composer Studio 1 Go to http processors wiki ti com index php Download CCS 2 Click the Download button for the latest production CCSv4 DVD image Download latest production CCS v4 DVD image 4 DOWNLOAD 3 Click the Download button to download the zip file You have been approved to receive this Software Click Download to proceed In a few moments you will also receive an email with the link to this file Save the zip file Extract the zip file Run setup CCS_x x x x exe You can use the default installation settings or only install the required components for the Stellaris family of devices Stellaris Cortex M3 CPUs and ARM Note This screen lists the CCS packages that are not yet installed so the screen may look different ee SS Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Downloading SYS BIOS Code Composer Studio v4 Setu
29. _freq 1 0x2000e674 task_low_freg 1 Ready toggle_low_freq 0x00000000 0x00000000 2048 0x20008940 0x2000e6b8 ti sysbios knl Task IdleTask 0 Ready ti_sysbios_kni_Idle_loop__E Ox00000000 Ox00000000 2048 0x20009140 priority mode fxn arg argi stackSize stackBase Running toggle_high_frea Ox00000000 0x00000000 2048 0x20008140 14 Explore the options available within the ROV Tool 15 Go to Tools gt RTA gt Exec Graph to open one of the Real Time Analysis Tools The RTA tools provide diagnostic information about the system execution including logs execution graphs and load data SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback eee Scripts Window Help Memory Map ED l Py l Wj Fa z GEL Files Qn Chip Flash he Ue i ARM Advanced Features Debugger Options Fort Connect Pin Connect RTSC Tools Profile ROV FA RTA a RTA Control Panel XDAIS Tools EA Raw Logs Trace Contral EA Printf Logs Graph gt FEW Exec Graph Data E Image Analyzer Ras CPU Load Res Thread Load EW CPU Load Data Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 39 Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com 16 In order to bypass the breakpoints placed in the code for the ROV tool Select Free Run from the drop down option next to the Run button Ue Oe Run CME I gt Free Run 17 At this p
30. a RTA Control Panel XDAIS Tools j EAH Raw Logs Trace Control FA Frintf Logs Trace Analyzer j Hus Exec Graph Graph EER Exec Graph Data E Image Analyzer Res CPU Load Re Thread Load B CPU Load Data Figure 17 Real Time Analysis Tools In addition to the RTA tools the Runtime Object Viewer ROV can analyze a SYS BIOS system This tool contains a list of the modules used in the program and displays detailed information about the selected module For example if the task module is selected the mode arguments stack size and other attributes of each of the tasks are updated when the program is paused or a breakpoint is encountered Find more information about the SYS BIOS debugging tools in the SYS BIOS User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 15 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated 3 16 I TEXAS INSTRUMENTS Downloading SYS BIOS www ti com Downloading SYS BIOS SYS BIOS is provided as part of Texas Instruments Code Composer Studio CCS Integrated Development Environment IDE SYS BIOS can also be downloaded as a stand alone component but this download process is not explained in this document For more information about the stand alone component visit the S
31. a UART interface Interrupting a task when the task is in the middle of printing a message generates a jumbled message on the output terminal Gates are similar to semaphores but are typically used to protect shared sections of software as opposed to hardware resources There are multiple types of pre defined gates that can be used or user defined gates can be created For example a gate would be used to protect the writing of a global variable to ensure that the variable is assigned a valid value by one task before another is allowed to access it Events are another specific implementation of a semaphore They require that several conditions exist before a pending thread returns from a pend call Note that only a single task can pend on an event at a time In the case of the UART example mentioned above the second task may want to ensure that the write buffer of the UART module is clear before the task begins writing data to the UART The task would set up an event to check the UART write buffer before pending on the semaphore Mailboxes are used to pass data buffers between tasks Events can be associated with mailboxes to allow for additional synchronization Mailboxes can be used to ensure that the flow of incoming buffers does not exceed the ability of the system to process those buffers For the purpose of this document only semaphores are covered in detail Additional information about other synchronization modules can be found in the SYS BIOS
32. abling the use of modules within a system e Right click the shaded box in the GUI OR e Right click the module in the Available Products list on the left side of the screen SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 3 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com Figure 3 shows the two methods for adding and removing modules in a SYS BIOS project Available Products X E type filter text g i SYS B1OS s105 A Communication EAA Diagnostics r Memory Management Al Realtime Analysis E ae Scheduling it Clock M wi 6 Use Id WE Swi bians Use Idle amp Tas Help OR we m Figure 3 Adding and Removing Modules Instances of enabled modules can be removed from or added statically to a program using two methods e Right click the shaded box in the GUI OR e Right click the item in the outline Figure 4 shows the two methods for creating a new task within a program Note that instances of modules can be created and configured dynamically at run time using calls to the SYS BIOS application programming interfaces APIs type filter text Bios Clock Defaults Diags Error Hwi Log LoggerBuf logger0 Main Memory Program Semaphore Swi l SysMin I kd Ld System Task New Task
33. aphore _pend mySem RUNNING gt RUNNING Figure 13 Task Continues to Run After Semaphore_Pend However if a task is running and the task calls the Semaphore_pend function on a semaphore with a count of 0 the task blocks as shown in Figure 14 my Task my Task Semaphore_pend mySem RUNNING BLOCKED Figure 14 Blocking a Task With a Semaphore To unblock the task another task must call the semaphore_post function to increment the count of the semaphore In the example in Figure 15 the lower priority task posts the semaphore to indicate that the task no longer requires access to the restricted resource The higher priority task is then switched from the blocked to the running state because the task was waiting for this resource to become available As soon as the task starts running the task pends on the semaphore to notify the program that the task is now using the resource controlled by the semaphore 12 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated ld TEXAS INSTRUMENTS www ti com Overview of SYS BIOS myLowPrilask Semaphore_post mySem RUNNING gt Hay E ASK Semaphore _pend mySem BLOCKED gt gt Figure 15 Unblocking a Task With a Semaphore Note that in the SYS BIOS kernel the first task in the semaphore queue n
34. aris_Example New itl Includes e main c Go Into amp app cfg Open in New Window La Im3sSb96 cmd makefile defs ig Set as Active Project Rebuild Index Active Build Configuration d Convert To Clean Project Build Project Rebuild Project 2 Connect the LM3S9B96 development kit to the PC 3 Set the project as the Active Project fd C C Projects X Oo Fa c i Stellaris_Example 7am L Indudes ic main c Go Into LA app cfg La Im3s9b96 cme makefile defs Open in New Window Set as Active Project SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 35 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated li TEXAS INSTRUMENTS Creating a Sample SYS BIOS Project www ti com 4 Click the green Debug button to load the code into the device and launch the debugger Be C C app cfg Code Composer Studio Licensed File Edit View Navigate Project Target Tools Scripts Window Help ee i ie JIE i E odh E W La a Hi Te Bi ae i i to G a Debug FSS n ait C C Projects of Target config BES Seu S app cfg X Ex E A SYS BIOS 5 When the Open Target Configuration Dialog appears click Yes Open Target Configuration You require a target configuration to startadebug session Do you want to eal create anew target configuration fle and open itin the edi
35. cludes H Debug Gc main c StellarisTargetConfigurati A app cfg La Im3s9b96 cmd makefile defs Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers New Go Into Open in New Window Dg Set as Active Project Rebuild Index Active Build Configuration Convert To Clean Project Build Project Rebuild Project Source Refactor a Refresh Close Project Debug As Team Compare With Restore from Local History Link Files Add Files Open Target Configuration Build Properties Debug Properties Properties Copyright 2012 Texas Instruments Incorporated SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 2 Click the nclude Options folder under the TIMS470 Compiler folder in the folder tree on the Tool Settings tab Click the Add button in the lower box that appears on the right hand side of the screen y Properties for Stellaris_Example type filter text Info Builders C C Build C C Documentation C C File Types C C Indexer CCS Build CCS Debug C C Build Active configuration Project Type Configuration Debug Je Configuration Settings EEEIEE IRES i Tool Settings Build Settings Build Steps Error Parsers Binary Parser Environment Macros Project References Refactoring
36. ction argument Default is 0 Task function argument Default is 0 Task priority 0 to numPriorities 1 or Task stack pointer Default null Task stack size in MAUs Mem section used for statically crea Mem heap used for dynamically cre Environment data struct Exit system immediately when the SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 16 Create a new semaphore by right clicking Semaphore and selecting New Semaphore type filter text BIOS Clock Defaults Diags Error Hwi Log LoggerBuf logger Main Memory Program SysMin Stop Using Semaphore System Help Gl Task task_high_freq task low freg Text 17 Edit the fields of the new semaphore instance as shown Click OK Create new Semaphore Params Name name Create Args count E Params event eventid mode SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Value Summary sem Name of the instance initial semaphore count null Event instance to use if non NULL 1 eventid if using Events Mode_BINARY Semaphore mode i Cancel Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 29 Copyright 2012 Texas Instruments Incorporated Creating a Sample SYS BIOS Project 30 18 Add the Age
37. ctivity www ti com automotive www ti com communications www ti com computers www ti com consumer apps www ti com energy www ti com industrial www ti com medical www ti com security www ti com space avionics defense www ti com video Mailing Address Texas Instruments Post Office Box 655303 Dallas Texas 75265 Copyright 2012 Texas Instruments Incorporated
38. d finally idle tasks which have the lowest implicit priority level The individual HWIs SWls and tasks can be assigned explicit priority levels that are secondary to the implicit priority levels On Stellaris devices the maximum number of hardware interrupt priorities is 8 the maximum number of software interrupt priorities is 32 and the maximum number of task priorities is 32 The priority levels assigned to HWIs in a SYS BIOS based program changes based on the hardware for which the code is compiled to run On Stellaris devices the highest priority HWI has a value of 0 and the lowest value depends on the number of priority levels defined for HWIs SWls and tasks inherit the SYS BIOS default priority levels such that the lowest priority has a value of 0 The highest priority level value for SWls and tasks depends upon the number of software interrupt priority levels and task priority levels that are implemented The preemptive priority based scheduler ensures that the highest priority thread that is ready to run is executed by the CPU A number of threads can be ready to execute at any given time but the thread with the highest priority executes first In order to switch between threads the context of the thread must be saved This context includes the program counter the stack and any relevant register values Specific stack functionality for each thread type is included in the following sections Hardware Interrupts Programs without an R
39. d zero latency interrupts are never disabled by the dispatcher 1 Globally disable all dispatcher managed interrupts but not zero latency interrupts for critical section protection Disable Task scheduler Disable SWI scheduler Save interrupt return pointer Call configured HWI begin hook functions Globally enable dispatcher managed interrupts but not zero latency interrupts if auto interrupt nesting support is enabled 7 Call ISR function 8 Globally disable dispatcher managed interrupts if auto interrupt nesting support is enabled 9 Call configured HWI end hook functions 10 Run the SWI scheduler which runs any SWIls that were posted by the ISR 11 Run Task scheduler which manages Task pre emption if required 12 Return from ISR oo SS Sy SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 7 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com 2 4 8 Do not use the interrupt keyword when defining a hardware interrupt within a SYS BIOS program since the Interrupt Dispatcher already handles the saving of the context The implementation of hardware interrupts depends on the specific device family With respect to the Stellaris Cortex M3 family of devices the hardware interrupts can be configured to use the Nested Vector Interrupt Controller NVIC The NVIC
40. ditor Active Build Configuration XDCscript Editor Exclude File s from Build 3 Copy System Editor i te In Place Editor MM Delete Default Editor Source gt Refactor gt K Refresh Add Bookmark Debug As Team Compare With Replace With eS Ce lt Properties Figure 1 Opening the cfg File Figure 2 shows the System Overview tab of the configuration tool that appears after the file opens crc app cfg Code Composer Studio Licensed Fle Edit View Navigate Project Target Tools Scripts Window Help t i Q F Fey C C Projects 3 20 app cfg 83 377 A SYS BIOS i a5 Stellaris_Example Active Debug E Q ores t a Induces S 5 Debug b 8 manc Threads T StelarisTargetConfiguration coml Ac amp app cfg m259 b96 cmd makefile defs i Semaphore Waibox Shaded boxes indicate D D anors iraani S i SYS BIOS kernel module Being BA Synchronizati G System i i E E Tornet svece spoon i ig E Memory i Check marks indicate E AA Devos a li i module is enabled lig Memory Management i aes O t t4 ndon L System SYS BIOS Source Figure 2 Configuration Tool Overview Each of the shaded blocks on the screen corresponds to a module within the SYS BIOS kernel The check mark in the lower left hand corner of the shaded box indicates that the module is enabled in the current configuration There are two methods for enabling and dis
41. e interrupt service routine ISR The SYS BIOS scheduler is wrapped around the system to ensure that the highest priority thread is executed as soon as the thread is ready and that program execution is returned to the Idle loop when the HWI completes execution The BlOS_start function starts the scheduler after the main program initializes the required hardware and peripherals in the main Init function An optional addition to a SYS BIOS program which is enabled in the default configuration is the Interrupt Dispatcher The Interrupt Dispatcher allows hardware interrupts to run properly with other threads because of its knowledge of the SYS BIOS scheduler Low priority threads are properly disabled when the higher priority tasks are executing The dispatcher also enables several of the debugging features that allow the user to see when interrupts occur The interrupt dispatcher is a piece of code that is common to all interrupts so the dispatcher can reduce the footprint size of the code The Interrupt Dispatcher consists of three components e Interrupt vectors the location of the dispatcher is patched into the interrupt vector table e Dispatch table contains parameters for the hardware interrupt e Interrupt stack saves the context when interrupts preempt each other Following is an outline of the operation of the Interrupt Dispatcher The steps in parentheses can be optimized out depending on the configuration of the system Configure
42. fault location Location Stellaris_ Example C Documents and Settings a0271819 My Documents SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Cancel Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Copyright 2012 Texas Instruments Incorporated 19 I TEXAS INSTRUMENTS Running an Existing SYS BIOS Project www ti com 5 Click Next Confirm that the ARM option is selected in the Project Type drop down menu New CCS Project Select a type of project Select the platform and configurations you wish to deploy on Project Type ARM Configurations ew e8neue SSS we Debug Select All tH Release Deselect All Show All Project Types Show All Configurations 6 Click Next In this case there will not be any referenced projects so leave all project boxes unchecked if any appear in the Referenced Projects field amp New CCS Project Additional Project Settings Define the inter project dependencies if any i Projects C C Indexer Referenced Projects Cancel 20 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Running an Existing SYS BIOS Project 7 Click Next Select Cortex M from the left Device Variant drop down menu Select the S
43. led by the SYS BIOS kernel Figure 9 shows how SWIs fit into the SYS BIOS architecture Hard Real time Hardware Interrupts Hwi Interrupt gt Urgent response time Foreground from hardware gt Often at sample rate gt Microseconds duty cycle gt Preemptive or non preemptive Swi_post from program gt Flexible processing time gt Often at frame rate gt Milliseconds duty cycle Software Interrupts Swi gt Preemptive Idle gt Best Effort Soft Real time gt Sequential Execution Background Figure 9 Hardware Versus Software Interrupts SWIs are made ready to run when the Swi_Post function is called typically by a hardware interrupt A SWI runs only once regardless of the number of times the SWI was posted prior to execution Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Overview of SYS BIOS Figure 10 shows how a system with hardware and software interrupts enabled processes the two threads Collect Samples Post Swi Process Buffer Highest Priority Hwi Swi Legend Idle LPM Running Lowest Priorty uur time Figure 10 HWI and SWI Example The HWI is used to collect samples in a periodic time frame and place them into a buffer The SWI is then used to process one
44. nt unless authorized officers of the parties have executed a special agreement specifically governing such use Only those Tl components which TI has specifically designated as military grade or enhanced plastic are designed and intended for use in military aerospace applications or environments Buyer acknowledges and agrees that any military or aerospace use of Tl components which have not been so designated is solely at the Buyer s risk and that Buyer is solely responsible for compliance with all legal and regulatory requirements in connection with such use Tl has specifically designated certain components as meeting ISO TS16949 requirements mainly for automotive use In any case of use of non designated products TI will not be responsible for any failure to meet ISO TS16949 Products Audio Amplifiers Data Converters DLP Products DSP Clocks and Timers Interface Logic Power Mgmt Microcontrollers RFID OMAP Applications Processors Wireless Connectivity www ti com audio amplifier ti com dataconverter ti com www dip com www ti com clocks interface ti com logic ti com power ti com microcontroller ti com www ti rfid com www ti com omap Applications Automotive and Transportation Communications and Telecom Computers and Peripherals Consumer Electronics Energy and Lighting Industrial Medical Security Space Avionics and Defense Video and Imaging TI E2E Community www ti com wirelessconne
45. nt module to enable the real time analysis tools for debugging include include include include fine lude include include include include include Q include Se EOE HE HE include extern S Available Products E type filter text s05 A Communication 4 Ciagnostics 4 sit Memory Management G LA Realtime Analysis se Agen Load g ia be aa Scheduling Help i 4 Synchroni Fe System i aa Target Sp 345 E 134 XDCtools 4 Diagnostic_ lt xdc std h gt lt xdc runtime Error h gt lt xdc runtime System h gt lt xdc runtime Log h gt lt ti sysbios BIOS h gt lt ti sysbios knl Task h gt lt ti sysbios knl Semaphore h gt inc hw_types h inc hw_memmap h inc lm3s9b96 h driverlib sysotl h driverlib gpio h emaphore_Handle sem Void toggle_low_freq whil eth Log_info0 toggle_low_freq Pend on the semaphore Log_info0 toggle_low_freg Semaphore_pend sem enter pend sem BIOS_WAIT_FOREVER Set the value of the GPIO pin low Log_info0 toggle_low_freg GPIOPinWrite GPIO_PORTA_BASE Sleep Log_info0 toggle_low_freq Task_sleep 10 pin low GPIO_PIN_6 sleep Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Refresh View Package Path Check Path Show Repositories ra Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUM
46. oint the following output should appear on GPIO pin PA6 of the development board The high frequency oscillations are created with the toggle_high_freq task while the lower frequency square wave envelope is created by the toggle_low_freq task Tek We Trig d MM Pos 0 0005 Measure 1 r SOUTE CH1 Type value sQ0 0Hz Back CHI 1 00 M S 00rnas CHI 120 250 000Hz 18 Halt the target Disassembly kaas T i E iE Stellaris_Example Debug Stellaris In Circuit Debug ace O CORTEX_M3_0 Project Debug Session ae Device Thread main Free Running 80 toggle _high_freg at main c 59 Ox0000033c 1 t_sysbios_knl_Task_exit_ EQ at Task c 371 Ox000024bc 2 xdc_runtime_LoggerBuf_write4_ F struct xdc_runtime_LoggerBuf_Object unsigned int unsigned short in z 3 lt symbol is not available gt Oxbebebebe pal Stellaris In Circuit Debug Interface _0 CORTEX_M3_0 9 25 32 AM pal Stellaris In Circuit Debug Interface_0 CORTEX_M3_0 CIO 9 25 32 AM 19 Observe the output in the Exec Graph window Console Se kA HERRAR A lalona Semaphore Event currentThread Unknown BIOS Scheduler toggle_high_freq0 dle scie toggle_low_freq 8 690 890 000 8 691 390 000 8 691 890 000 8 692 390 000 8 692 890 000 time ns 20 Explore the options available within the RTA Exec Graph Tool 40 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentati
47. on Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Conclusion Find more information about the SYS BIOS debugging tools in the SYS B IOS User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio 6 Conclusion The SYS BIOS kernel provides a basis for developing applications that require precise timing and instrumentation The debugging features of the SYS BIOS software package provide valuable insight into the execution state of the program at various stages of execution The graphical configuration utility allows for quick and easy manipulation of the kernel settings and modules Creating a project to run on Stellaris Cortex M3 devices is a straight forward process that is facilitated by the use of the provided SYS BIOS project templates Overall SYS BIOS provides a robust portable structure for programming real time applications 7 References The following related documents are available on the Stellaris web site at www ti com stellaris e Stellaris LM3S9B96 Microcontroller Data Sheet literature number SPMS182 e StellarisWare Driver Library Available for download at www ti com tool sw drl e Stellaris Peripheral Driver Library User s Guide publication SW DRL UG literature number SPMU019 e StellarisWare software Available for download at www ti com tool sw lm3s The Texas Instruments Embedded Processors Wiki
48. one of these examples and running the example on a target device For the purpose of the example project the Stellaris DK LM3S9B96 development board is used However any of the Stellaris Cortex M3 devices can be substituted and used as the platform for this example 1 Launch CCS from Start gt All Programs gt Texas Instruments gt Code Composer Studio v4 2 x gt Code Composer Studio v4 2 Make sure that the C C perspective is selected in CCS F Debug Fie C C 18 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com 3 Select File gt New gt CCS Project Running an Existing SYS BIOS Project K C C Code Composer Studio Licensed mim Edit View Navigate Project Target Tools Scrip ts Window Help New File Open File Atasha Uti CoSProject Standard Make Project C Folder Di Source File Shift Cii Header File Fie GF Class H Target Configuration File e DSP BIOS v5 x Configuration File Refresh 8 New CCS Project CCS Project Create a new CCS Project Convert Line Delimiters To RTSC Configuration File Fy Other Project name Use de
49. ot necessarily the higher priority task is the first to unblock This means that the first task that blocked is the first one that will be made ready to run when the semaphore is posted Another important note is the fact that multiple tasks can block on the same semaphore as Figure 16 illustrates where both the high and medium priority tasks are waiting on the same semaphore Since the medium priority task was the first to pend on the semaphore the medium priority task is allowed to execute before the higher priority task This type of priority inversion can be prevented with the use of a specific type of gate called a GateMutexPri ONAE Semaphore_post mySem RUNNING gt PriTask medk iilas Semaphore_pend mySem BLOCKED RUNNING hiPri Task Semaphore _pend mySem BLOCKED gt Figure 16 Unblocking a Task With a Semaphore When Multiple Tasks Are Blocked Find more information about the SYS BIOS semaphores in the SYS B OS User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 13 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Overview of SYS BIOS www ti com 2 7 Timers and Clocks 14 Timers and clocks can be configured within SYS BIOS to maintain portability bet
50. p Choose ISA Select ISA support to be installed MSP430 16 bit Ultra Low Power MCUs C28x 32 bit Real time MCUs Stellaris Cortex 43 MCUs Cortex R4F MCUs W Digital Media amp Application Processors OMAP DaVinci and Sitara C54x DSPs c55x DSPs C6000 DSPs ARM Cancel 8 Click Next SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers 17 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated I TEXAS INSTRUMENTS Running an Existing SYS BIOS Project www ti com 9 Make sure that the DSP BIOS 6 x and XDCtools boxes are checked on the next installer window Code Composer Studio v4 Setup Select Components Select the components you want to install and deselect the components you do not want to install eR r pe A Description Integrated Development Environment Code Generation Tools VE ILORI DSP BIOS Operating System Notes XDC is required DSP BIOS 6 x please check it A i wt 1 56 GB of space required to install selected configuration 88 42 GB is available on the qurrent drive 10 Click Next and CCS installs to the selected directory 11 Click Finish when the installer completes 4 Running an Existing SYS BIOS Project The SYS BOIS software package comes with several examples programs that showcase the features and capabilities of the kernel The following steps outline the process of opening
51. r Application Report l ANS NTA SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers Peggy Liska Stellaris Microcontrollers ABSTRACT This document provides a brief overview of the Texas Instruments SYS BIOS Real Time Operating System RTOS and outlines how to implement SYS BIOS on the Stellaris ARM Cortex M3 family of microcontrollers In addition to setting up and running an example project provided within the SYS BIOS software package this document outlines the process of creating a new SYS BIOS project with the Code Composer Studio v4 2 CCS integrated development environment IDE As a final step this document outlines the integration of the StellarisWare Application Programming Interfaces APIs into a SYS BIOS project Contents 1 DEOK ION sit acc cn saws sen E cevaumenacwad wbue sot uiu E E guts oes 2 2 OVEIVIEW 0 5 2 DIO decawatae aaamnecscaaeecte cues cau ESE 2 3 Downloading SYS BIUS anceussicacacensaancaee avactnenence eaeanen pean cu eaatranscanaessasaneaonsanecescsterarerenenueocin 16 4 AUN an Existing SY O BIOS ProjeCl siacacreveeccsevemsvtrssscedeneeatexesecsiaipicaxacetccaccurserncodseueeccaesne 18 5 Creating a Sample SYS BIOS Projeeh icseswessecctensdeiesccscsaeediebscedivbleacdvendecsesaeaccedasevsedaveiensayedies 22 6 SOT S NO eene E R E ES A AE EE E passa tis E inane apeanae enore eras 41 7 FIGIGICNCES Seswwenecenatesewaat ei A EE a E r
52. ree on the Tool Settings tab Click the Add button in the upper box that appears on the right hand side of the screen Properties for Stellaris_Example Filtered type filter text Be C C Build C C Build Active configuration CCS Build Project Type Configuration Debug J Configuration Settings Tool Settings Build Settings Build Steps Error Parsers Binary Parser Environment Macros 83 Tool chain Settings Include library file or command file as input ibrary aw E B TMS470 Compier a gs Basic Options amp Symbolic Debug Options 3 Language Options Parser Preprocessing Options amp Predefined Symbols 3 Include Options r amp Diagnostic Options Add lt dir gt to library search path search_path 1 3 Runtime Model Options LSCG TOOL ROOT fib i bma S CG_TOOL_ROOT indude gt l gt Entry Exit Hook Options Library Function Assumptions Assembler Options 83 File Type Specifier a d Directory Specifier Disable automatic RTS selection disabie_suto_rts Default File Extensions Ee ree eee amp Command Files MISRA C 2004 MISRA Rules TMS470 Linker gs Basic Options Command File Preprocessing Diagnostics 3 File Search Path g amp Linker Output amp Symbol Management g Runtime Environment 3 Linktime Optimization eg Miscellaneous 2 Dynamic Linking Support Options E xDCtools amp Package Repositories
53. s terminated Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated l TEXAS INSTRUMENTS www ti com Overview of SYS BIOS 2 6 Figure 12 displays the four task states and how the tasks transition between them Semaphore_post Task Mode READY UE aea Task_yield Task is preempted Task_Mode_ RUNNING Task_sleep Task_exit Task exits Task_Mode_TERMINATED Task_create Task is created Task runs Task_delete Task is deleted Semaphore_pend Task suspends Task_Mode BLOCKED Figure 12 Task State Diagram Find more information about the SYS BIOS tasks in the SYS BIOS User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Synchronization Modules The SYS BIOS kernel provides several different modules for synchronizing tasks within the system These include semaphores gates events and mailboxes Semaphores are typically used to protect a hardware resource that is accessed by multiple tasks Using a semaphore ensures that the task that is accessing the hardware resource completes its action before allowing another task to take control of the resource An example of an application where a semaphore is useful is when multiple tasks need to write data to
54. tellaris device you are using from the drop down menu to the right of the Cortex M selection New CCS Project Project Settings Select the project settings Output type Executable Project settings Device Variant Cortex M al Stellaris LM359896 Device Endianness litte Code Generation tools EE v4 9 0 ka More output Format eabi ELF e Linker Command File lt automatic gt w Browse 8 Click Next Under the SYS BIOS folder select Generic Examples Clicking each of the examples displays an explanation of the example in the right hand window Select the Log Example New CCS Project Project Templates Select one of the available project templates H E Empty Projects This module shows how to use Log_infoG Log error ET a and Log warning in a simple application It shows t i Basic Examples Y a 5 P how to enable USER logs for the Task module in the 2 j IPC and 1 0 Examples cfg file E sys B1as ae Minimal ia a Typical ae Pi Typical with separate config project j E Generic Examples p p C Example bigtime i pl Clock Example a Error Example Event Example L ka Hello Example E Log Example say Memory Example i E Small Example p Stairstep Example i pi Static Example ola Swi Example i la Task Example separate config project te FE Task Mutex Example SPMA040A January 2012 Revised November 2012 Using SYS BIOS With Stellaris ARM Cortex
55. ter n 12 Run the debugger amp Debug main c Code Composer Studio Licensed Window File Edit View Navigate Project Target Tools Scripts Ee oa Sa TEB As Debug gl o EN i re S i ae al 72 Device k Thread main Suspended 0 mang at main c 30 Ox00003462 1 args main at args_main c 93 Ox00004fa Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers w Help T TET a 2 a ee te E Stellaris_Example Debug Run In Circuit peh g Interface _O CORTEX_M3_0 Project Debug Session ee ee Se Ee bel Stellaris In Circuit Debug Interface _O CORTEX_M3_0 3 28 10 PM eJ Stellaris In Circuit Debug Interface _O CORTEX M3 0 CIO 3 28 10 PM SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 13 When the target halts at the first breakpoint open the ROV tool and observe the task details The state of each task is displayed along with other details about each task Console pa s ae Fia Stellaris_Example out S Viewable Modules mo wom z fay oO Pa D to A L Load LoggerBuf Queue Registry Semaphore Startup Swi Timer All Modules HB i i GB xdc ugn Basic Detailed Module Raw address label 0x2000e630 task_high
56. tor amp New Target Configuration Target Configuration Create a new Target Configuration file File name StellarisTargetConfiguration ccxml C Use shared location Location Stellaris_Example Workspace 36 Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012 Submit Documentation Feedback Copyright 2012 Texas Instruments Incorporated la TEXAS INSTRUMENTS www ti com Creating a Sample SYS BIOS Project 7 Select Stellaris In Circuit Debug Interface in the Connection drop down menu Select your device from the Device window app ctg Ei StellarisTargetConfiguration coml 4 Basic General Setup Advanced Setup This section describes the general configuration about the target Connection etellaris In Circuit Debug Interface we Target Confiquration lists the configuration options for the target Device type filter text Save Configuration C Stellaris LM359997 _ Stellaris LM3595681 C Stellaris LM359890 C Stellaris LM359692 C Stellaris LM359B95 C Stellaris LM3S9BN2 C Stellaris LM3S9BN5 C Stellaris LM3598N6 C Stellaris LM3S9C97 lt iiil Note Support for more devices may be available fom the update manager Basic Advanced Source 8 Click Save 9 If the CCS Debug perspective does not launch automatically change the perspective by clicking Debug in the top right hand corner of the screen EG Debug
57. ulation of the RTOS components such as tasks interrupts and semaphores This GUI is incorporated into CCS and automatically generates the required initialization code for configuring the SYS BIOS kernel The remainder of this document describes the SYS BIOS kernel in detail and the process of implementing a SYS BIOS based project on a Stellaris ARM Cortex M3 microcontroller More detailed information about the SYS BIOS RTOS can be found in documents listed in Section 7 References Overview of SYS BIOS SYS BIOS is an RTOS kernel designed by Texas Instruments to run on a variety of TI microcontrollers SYS BIOS provides the following features e Preemptive priority based scheduler e Memory allocation and stack management O services The preemptive priority based scheduler ensures that the highest priority thread that is ready to run is executed by the system This configuration ensures that time sensitive computations are handled with a minimum amount of latency The SYS BIOS kernel can be optimized for custom projects in order to improve the code size of the final application Detailed timing and size benchmark information can be found on the SYS BIOS Wiki page located on the Texas Instruments Embedded Processor Wiki An advantage of using SYS BIOS is the application portability between TI digital signal processors DSPs ARM based microcontrollers and MSP430 microcontrollers The abstraction accomplished by the RTOS allows for code
58. vices with statements different from or beyond the parameters stated by TI for that component or service voids all express and any implied warranties for the associated Tl component or service and is an unfair and deceptive business practice Tl is not responsible or liable for any such statements Buyer acknowledges and agrees that it is solely responsible for compliance with all legal regulatory and safety related requirements concerning its products and any use of Tl components in its applications notwithstanding any applications related information or support that may be provided by TI Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which anticipate dangerous consequences of failures monitor failures and their consequences lessen the likelinood of failures that might cause harm and take appropriate remedial actions Buyer will fully indemnify Tl and its representatives against any damages arising out of the use of any Tl components in safety critical applications In some cases Tl components may be promoted specifically to facilitate safety related applications With such components Tl s goal is to help enable customers to design and create their own end product solutions that meet applicable functional safety standards and requirements Nonetheless such components are subject to these terms No Tl components are authorized for use in FDA Class III or similar life critical medical equipme
59. ween TI microcontrollers When the SYS BIOS timer module is used the kernel manages the hardware timer peripherals on the device Timer threads are run within the context of a HWI thread The SYS BIOS clock module layers on top of the timer modules and manages the RTOS time base The clock module allows functions to be fired as one shot timers or periodically using the functionality and priority of a software interrupt SWI Clocks run at the same SWI priority so they cannot preempt each other In the case of the Stellaris Cortex M3 the SysTick timer in the core can be used as the RTOS time base by adding the following lines into the configuration file var halTimer xdc useModule ti sysbios hal Timer halTimer TimerProxy xdc useModule ti sysbios family arm m3 Timer More information about using specific Cortex M3 timers in a SYS BIOS application can be found on the SYS BIOS for Stellaris Devices Wiki page In addition to the timer and clock module a timestamp module is provided as a component of the SYS BIOS architecture This module is useful for benchmarking applications that require precise timing measuremenis Find more information about the SYS BIOS timers and clocks in the SYS B OS User s Manual in the SYS BIOS section of the Help Contents found in the Help gt Help Contents menu of Code Composer Studio Using SYS BIOS With Stellaris ARM Cortex M3 Microcontrollers SPMA040A January 2012 Revised November 2012
Download Pdf Manuals
Related Search
Related Contents
OKS 571 FreePlay EN ES FR DE 89575_Druckluft-Fuellpistole_Faltblatt (480x630)_LB2.indd Samsung HMX-W200RP Εγχειρίδιο χρήσης TAG770 Manuel utilisation.qxp - TAG Bryant PSPHA732 Thermostat User Manual Valor de la Procalcitonina como Biomarcador Específico y Precoz Homeowners Guide Manual 443 - Liberty Electric Bikes Model No. PT-FW100NTU Copyright © All rights reserved.
Failed to retrieve file