f2806x Dev User Guide
f2806x Dev User Guide
f2806x Dev User Guide
USER’S GUIDE
Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of Texas Instruments semicon-
ductor products and disclaimers thereto appears at the end of this document.
Texas Instruments
13905 University Boulevard
Sugar Land, TX 77479
http://www.ti.com/c2000
Revision Information
This is version 2.06.00.00 of this document, last updated on Sat Feb 13 03:33:30 CST 2021.
Table of Contents
Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Revision Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Header File Quickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 Device Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Understanding The Peripheral Bit-Field Structure Approach . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Peripheral Example Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Steps for Incorporating the Header Files and Sample Code . . . . . . . . . . . . . . . . . . . . . . . 24
2.6 Troubleshooting Tips and Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.7 Migration Tips for moving from the TMS320x280x header files to the TMS320x2806x header files . 33
2.8 Packet Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.9 Detailed Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3 Getting Started with Project Creation and Debugging . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.2 Project Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.3 Debugging Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.4 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4 Piccolo F2806x Example Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.1 ADC Start of Conversion (adc_soc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2 ADC Temperature Sensor (adc_temp_sensor) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.3 ADC Temperature Sensor Conversion (adc_temp_sensor_conv) . . . . . . . . . . . . . . . . . . . . 60
4.4 USB Boot Loader Example (boot_demo_usb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.5 CLA ADC (cla_adc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.6 CLA ADC FIR (cla_adc_fir) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.7 CLA ADC FIR FLASH (cla_adc_fir_flash) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.8 Cpu Timer (cpu_timer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.9 DMA RAM to RAM Transfer (dma_ram_to_ram) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.10 eCAN back to back (ecan_back2back) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.11 eCAP APWM (ecap_epwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.12 eCAP capture PWM (ecap_capture_pwm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.13 ePWM Blanking Window (epwm_blanking_window) . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.14 ePWM DC Event Trip (epwm_dcevent_trip) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.15 ePWM DC Event Trip Comparator (epwm_dcevent_trip_comp) . . . . . . . . . . . . . . . . . . . . . 66
4.16 ePWM Deadband Generation (epwm_deadband) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.17 ePWM Real-Time Interrupt (epwm_real-time_interrupts) . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.18 ePWM Timer Interrupt (epwm_timer_interrupts) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.19 ePWM Trip Zone (epwm_trip_zone) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.20 ePWM Action Qualifier Module using Upcount mode (epwm_up_aq) . . . . . . . . . . . . . . . . . . 68
4.21 ePWM Action Qualifier Module using up/down count (epwm_updown_aq) . . . . . . . . . . . . . . . 68
4.22 eQEP, Frequency measurement(eqep_freqcal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.23 eQEP Speed and Position measurement (eqep_pos_speed) . . . . . . . . . . . . . . . . . . . . . . 72
4.24 External Interrupt (external_interrupt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.25 F28069 CAN Flash Kernel (f28069_can_flash_kernel) . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.26 F28069 SCI Flash Kernel (f28069_sci_flash_kernel) . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.27 ePWM Timer Interrupt From Flash (flash_f28069) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.28 Flash Programming (flash_programming) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.29 FPU Hardware(fpu_hardware) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
1 Introduction
The Texas Instruments® F2806x Firmware Development Package is a collection of device header
files, common source files, helper libraries and example applications for the 2806X line of devices
in the Piccolo portfolio.
The package comes with a complete set of example projects that demonstrate the basics of getting
started with a Piccolo device and working with its different peripheral modules.
Chapter 2 talks about how the software package is structured, how the header files are organized
and used in the example applications. The peripheral bit-field structure approach is presented
in detail along with step-by-step instructions on how to use it in your code. A complete revision
history of the header files is provided at the end of the chapter.
Chapter 3 provides step-by-step instructions on how to create a project from scratch and then go
about debugging it. Its a good place to start if this is your first interaction with a piccolo device.
Chapter 4 covers all the examples provided in the development package; what each example does,
its setup and observation procedures and, in a few cases, the mathematics involved in setting up
control values for peripherals.
The examples for Piccolo(2806x) can be found in the examples\c28 directory. As users move past
evaluation, and get started developing their own application, TI recommends they maintain a similar
project directory structure to that used in the example projects.
Chapter 5 provides details on the prototype CLA compiler including implementation of the C lan-
guage as well as restrictions.
Chapter 6 covers the examples that demonstrate the use of the CLA compiler.
1. Appendix A - describes the default hardware prioritizing of Interrupt Software Routines and
how it can be over-ridden in software.
2. Appendix B - Each factory programmed device from TI has compensation routines in OTP
memory for oscillator drift due to temperature fluctuations. These routines are described here.
3. Appendix C- is the errata to version 6 of the Scale Factor Optimization Library. It describes
updates to any of the SFO v6 library files
2.2 Introduction
The F2806x C/C++ peripheral header files and example projects facilitate writing in C/C++ Code
for the Texas Instruments TMS320xF2806x devices. The code can be used as a learning tool or as
the basis for a development platform depending on the current needs of the user.
1. Learning Tool
This download includes several example Code Composer StudioT M v 6.0+ 1 projects for a
F2806x development platform.
These examples demonstrate the steps required to initialize the device and utilize the on-chip
peripherals. The provided examples can be copied and modified giving the user a platform to
quickly experiment with different peripheral configurations.
These projects can also be migrated to other devices by simply changing the memory alloca-
tion in the linker command file.
2. Development Platform
The peripheral header files can easily be incorporated into a new or existing project to provide
a platform for accessing the on-chip peripherals using C or C++ code. In addition, the user
can pick and choose functions from the provided code samples as needed and discard the
rest.
1. Overview of the bit-field structure approach used in the F2806x C/C++ peripheral header files.
1 Code Composer Studio is a trademark of Texas Instruments (www.ti.com).
Finally, this document does not provide a tutorial on writing C code, using Code Composer Studio,
or the C28x Compiler and Assembler. It is assumed that the reader already has a F2806x hardware
platform setup and connected to a host with Code Composer Studio installed. The user should have
a basic understanding of how to use Code Composer Studio to download code through JTAG and
perform basic debug operations.
Bug fixes to the source files. A detailed revision history can be found in 2.9.
13. Version 1.20
Release of the C compiler for the CLA - New examples demonstrating the programming
model of the C compiler are available in this version with accompanying documentation.
A detailed revision history can be found in 2.9.
14. Version 1.15
This version includes a new USB bootloader. A detailed revision history can be found in
2.9.
15. Version 1.10
This version includes code corrections and comment fixes to the header files and exam-
ples, and also adds new examples. A detailed revision history can be found in 2.9.
16. Version 1.00
This version is the first release of the F2806x header files and examples. It is an internal
release used for customer trainings and tools releases.
Under the headers and common directories the source files are further broken down into sub-
directories each indicating the type of file. Table 2.2 lists the sub-directories and describes the
types of files found within each:
Directory Description
<base> Base install directory
<base>\docs Documentation including the revision history from the previous
release.
<base>\headers Files required to incorporate the peripheral header files into a
project. The header files use the bit-field structure approach de-
scribed in Section 2.3. Integrating the header files into a new or
existing project is described in Section 2.5.
<base>\examples\c28 Example Code Composer Studio v6 projects. These example
projects illustrate how to configure many of the on-chip peripher-
als. An overview of the examples is given in Section 2.4.
<base>\examples\cla CLA examples(Built with CLA C compiler). These example
projects illustrate the programming model of the CLA in C.
<base>\common Common source files shared across example projects to illustrate
how to perform tasks using header file approach. Use of these
files is optional, but may be useful in new projects. A list of these
files is in Section 2.8.
<base>\MWare Specific peripheral(e.g. USB) libraries, code and header files.
Sub-Directory Description
headers\cmd Linker command files that allocate the bit-field structures de-
scribed in Section 2.3.
headers\source Source files required to incorporate the header files into a new or
existing project.
headers\include Header files for each of the on-chip peripherals.
common\cmd Example memory command files that allocate memory on the
devices.
common\include Common .h files that are used by the peripheral examples.
common\source Common .c files that are used by the peripheral examples.
common\targetConfigs Common target configuration (.ccxml) files that are used by the
peripheral examples.
1. Have a hardware platform connected to a host with Code Composer Studio installed
NOTE: As supplied, the F2806x example projects are built for the F28069 device. If
you are using another F2806x device, the memory definition in the linker command file
(.cmd) will need to be changed and the project rebuilt.
2. Open the example project Each example has its own project directory which is “im-
ported”/opened in Code Composer Studio v6. To open the F2806x CPU-Timer example
project directory, follow the following steps:
In Code Composer Studio v 6.x: Project->Import Existing CCS/CCE Eclipse Project.
Next to “Select Root Directory”, browse to the CPU Timer example directory: exam-
ples\c28\cpu_timer. Select the Finish button. This will import/open the project in the
CCStudio v6.x C/C++ Perspective project window.
3. Edit F2806x_Device.h Edit the F2806x_Device.h file and make sure the appropriate device
is selected. By default the F28069 is selected.
/********************************************************************
headers\include\F2806x_Device.h
********************************************************************/
#define TARGET 1
//
// User To Select Target Device:
//
#define DSP28_28062P 0
#define DSP28_28062UP 0
#define DSP28_28062PZ 0
#define DSP28_28062UPZ 0
...
...
...
#define DSP28_28069P 0
#define DSP28_28069UP 0
#define DSP28_28069PZ 0
#define DSP28_28069UPZ TARGET
4. Edit F2806x_Examples.h Edit F2806x_Examples.h and specify the clock rate, the PLL control
register value (PLLCR and DIVSEL). These values will be used by the examples to initialize
the PLLCR register and DIVSEL bits.
The default values will result in a 90MHz SYSCLKOUT frequency.
/********************************************************************
common\include\F2806x_Examples.h
********************************************************************/
/*-------------------------------------------------------------------
Specify the PLL control register (PLLCR) and divide
select (DIVSEL) value.
--------------------------------------------------------------------*/
//#define DSP28_DIVSEL 0 // Enable /4 for SYSCLKOUT(default at reset)
//#define DSP28_DIVSEL 1 // Disable /4 for SYSCKOUT
#define DSP28_DIVSEL 2 // Enable /2 for SYSCLKOUT
//#define DSP28_DIVSEL 3 // Enable /1 for SYSCLKOUT
//#define DSP28_PLLCR 15
//#define DSP28_PLLCR 14
//#define DSP28_PLLCR 13
//#define DSP28_PLLCR 12
...
...
//#define DSP28_PLLCR 3
//#define DSP28_PLLCR 2
//#define DSP28_PLLCR 1
//#define DSP28_PLLCR 0 // PLL is bypassed in this mode
//-------------------------------------------------------------------
In F2806x_Examples.h, also specify the SYSCLKOUT rate. This value is used to scale a delay
loop used by the examples. The default value is for a 80 MHz SYSCLKOUT.
/********************************************************************
common\include\F2806x_Examples.h
********************************************************************/
...
#define CPU_RATE 12.500L // for a 80MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 16.667L // for a 60MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 25.000L // for a 40MHz CPU clock speed (SYSCLKOUT)
...
5. Review the comments at the top of the main source file: Example_2806xCpuTimer.c A
brief description of the example and any assumptions that are made and any external hard-
ware requirements are listed in the comments at the top of the main source file of each exam-
ple. In some cases you may be required to make external connections for the example to work
properly.
6. Perform any hardware setup required by the example Perform any hardware setup indi-
cated by the comments in the main source. The CPU-Timer example doesn’t require any
hardware to be setup. Other examples may require additional hardware configuration such
as connecting pins together or pulling a pin high or low. Table 2.3 shows a listing of the boot
mode pin settings for your reference. Table 2.4 and Table 2.5 list the EMU boot modes (when
emulator is connected) and the Get Mode boot mode options (mode is programmed into OTP)
respectively. Refer to the documentation for your hardware platform for information on config-
uring the boot mode pins. For more information on the F2806x boot modes refer to the device
specific Boot ROM chapter in the Technical Reference Manual.
When the emulator is connected for debugging: TRSTn = 1, and therefore the device is in
EMU boot mode. In this situation, the user must write the key value of 0x55AA to EMU_KEY
at address 0x0D00 and desired EMU boot mode value to EMU_BMODE at 0x0D01 via the
debugger window according to Table 2.4.
When the emulator is not connected for debugging: SCI or Parallel I/O boot mode can be
selected directly via the GPIO pins, or OTP_KEY at address 0x3D7BFB and OTP_BMODE at
address 0x3D7BFE can be programmed for the desired boot mode per Table 2.5.
7. Build and Load the code
Once any hardware configuration has been completed, in Code Composer Studio v6, go to
Run->Debug. Your program should halt at the main function. This will load the compiled .OUT
image to the device.
8. Run the example, add variables to the watch window or examine the memory contents
At the top of the code in the comments section, there should be a list of “Watch variables”.
To add these to the watch window, highlight them and right-click. Then select Add Watch
expression. Now variables of interest are added to the watch window.
9. Experiment, modify, re-build the example If you wish to modify the examples it is suggested
that you make a copy of the entire header file packet to modify or at least create a backup of
the original files first. New examples provided by TI will assume that the base files are as
supplied.
Sections 2.4.2 and 2.4.2.3 describe the structure and flow of the examples in more detail.
10. When done, delete the project from the Code Composer Studio v6 workspace
Go to View->C/C++ Projects to open up your project view. To remove/delete the project from
the workspace, right click on the project’s name and select delete. Make sure the Do not
delete contents button is selected, then select Yes. This does not delete the project itself. It
merely removes the project from the workspace until you wish to open/import it again.
The examples use the header files in the headers directory and shared source in the common
directory. Only example files specific to a particular example are located within the example
directory.
NOTE: Most of the example code included uses the “.bit” field structures to access
registers. This is done to help the user learn how to use the peripheral and device.
Using the bit fields has the advantage of yielding code that is easier to read and modify.
This method will result in a slight code overhead when compared to using the “.all”
method. In addition, the example projects have the compiler optimizer turned off. The
user can change the compiler settings to turn on the optimizer if desired.
Each of the example programs has a very similar structure. This structure includes unique source
code, shared source code, header files and linker command files.
/********************************************************************
examples\c28\cpu_timer\Example_2806xCpuTimer.c
********************************************************************/
DSP28x_Project.h
This header file includes F2806x_Cla_typedefs.h, F2806x_Device.h and F2806x_Examples.h.
Because the name is device-generic, example/custom projects can be easily ported between
different device header files. This file is found in the <base>\common\include directory.
F2806x_Cla_typedefs.h
This file redefines the ANSI C standard data types like int, short etc to fit the native bit-width
of the CLA architecture. This file is found in the <base>\common\include directory.
F2806x_Device.h
This header file is required to use the header files. This file includes all of the required periph-
eral specific header files and includes device specific macros and typedef statements. This
file is found in the <base>\headers\include directory.
F2806x_Examples.h
This header file defines parameters that are used by the example code. This file is not required
to use just the F2806x peripheral header files but is required by some of the common source
files. This file is found in the <base>\common\include directory.
Each of the example projects consists of source code that is unique to the example as well as
source code that is common or shared across examples.
F2806x_GlobalVariableDefs.c
Any project that uses the F2806x peripheral header files must include this source file. In
this file are the declarations for the peripheral register structure variables and data section
assignments. This file is found in the <base>\headers\source directory.
Example specific source code
Files that are specific to a particular example have the prefix Example_2806x in their
filename. For example Example_2806xCpuTimer.c is specific to the CPU Timer exam-
ple and not used for any other example. Example specific files are located in the
<base>\examples\c28\<example> directory.
Common source code
The remaining source files are shared across the examples. These files contain common
functions for peripherals or useful utility functions that may be re-used. Shared source files
are located in the common\source directory. Users may choose to incorporate none, some, or
the entire shared source into their own new or existing projects.
Each example uses two linker command files. These files specify the memory where the linker will
place code and data sections. One linker file is used for assigning compiler generated sections
to the memory blocks on the device while the other is used to assign the data sections of the
peripheral register structures used by the F2806x peripheral header files.
2.4.2.3 Documentation
This document is linked into each project so it can easily be opened through the project view. To
do this, right click on the document within CCS, select “open with” and “system editor”.
the PWM timer interrupt example with the following changes made to execute out of flash:
The ramfuncs section is then assigned to a load address in flash and a run address in SARAM
by the memory linker command file as shown below:
/********************************************************************
common\include\F28069.cmd
********************************************************************/
SECTIONS
{
ramfuncs : LOAD = FLASHA,
RUN = RAML0,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
LOAD_SIZE(_RamfuncsLoadSize),
PAGE = 0
}
The linker will create symbols for the block “ramfuncs”. These are described in the Table 2.8.
Address Symbol
Load start address RamfuncsLoadStart
Load end address RamfuncsLoadEnd
Run start address RamfuncsRunStart
Load Size RamfuncsLoadSize
These symbols can then be used to copy the functions from the Flash to SARAM using the C
library standard memcpy() function.
To perform this copy from flash to SARAM using the included example memcpy() function:
(c) Modify the code to call the example memcpy function for each section that needs to be
copied from flash to SARAM.
/********************************************************************
examples\c28\Flash source file
********************************************************************/
InitFlash();
5. Set the required jumpers for “boot to Flash” mode The required jumper settings for each
boot mode are shown in Table 2.3, Table 2.4, and Table 2.5.
#include "F2806x_Device.h"
Another option is to #include “DSP28x_Project.h” in your source files, which in-turn includes
“F2806x_Cla_typedefs.h”,“F2806x_Device.h” and “F2806x_Examples.h” (if it is not necessary
to include common source files in the user project, the #include “F2806x_Examples.h” line
can be deleted). Due to the device-generic nature of the file name, user code is easily ported
between different device header files.
/********************************************************************
User’s source file
********************************************************************/
#include "DSP28x_Project.h"
2. Edit F2806x_Device.h and select the target you are building for
In the below example, the file is configured to build for the 28069 device.
/********************************************************************
headers\include\F2806x_Device.h
********************************************************************/
#define TARGET 1
//
// User To Select Target Device:
//
#define DSP28_28062P 0
#define DSP28_28062UP 0
#define DSP28_28062PZ 0
#define DSP28_28062UPZ 0
...
...
...
#define DSP28_28069P 0
#define DSP28_28069UP 0
#define DSP28_28069PZ 0
#define DSP28_28069UPZ TARGET
By default, the 28069 device is selected.
3. Add the source file F2806x_GlobalVariableDefs.c to the project
This file is found in the headers\source directory and includes:
Declarations for the variables that are used to access the peripheral registers.
Data section #pragma assignments that are used by the linker to place the variables in
the proper locations in memory.
4. Add the appropriate F2806x header linker command file to the project. As described in
Section 2.4, when using the F2806x header file approach, the data sections of the peripheral
register structures are assigned to the memory locations of the peripheral registers by the
linker.
To perform this memory allocation in your project, one of the following linker command files
located in headers\cmd must be included in your project:
For non-DSP/BIOS2 projects: F2806x_Headers_nonBIOS.cmd
For DSP/BIOS projects: F2806x_Headers_BIOS.cmd
The method for adding the header linker file to the project depends on preference
Method #1:
Right-click on the project in the project window of the C/C++ Projects perspective.
Select Link Files to Project...
Navigate to the headers\cmd directory on your system and select the desired .cmd file.
Note: The limitation with Method #1 is that the path to <install direc-
tory>\headers\cmd\<cmd file>.cmd is fixed on your PC. If you move the installation
directory to another location on your PC, the project will “break” because it still expects
the .cmd file to be in the original location. Use Method #2 if you are using “linked
variables” in your project to ensure your project/installation directory is portable
across computers and different locations on the same PC. For more information, see:
2 DSP/BIOS is a trademark of Texas Instruments
Method #2:
Right-click on the project in the project window of the C/C++ Projects perspective.
Select New->File.
Click on the Advanced» button to expand the window.
Check the Link to file in the file system check-box.
Select the Variables... button. From the list, pick the linked variable associated with your
installation directory. (e.g. INSTALLROOT_2806X). For more information on linked vari-
ables, see: C2000 Getting Started with Code Composer Studio v6
Click on the Extend... button. Navigate to the desired .cmd file and select OK.
5. Add the directory path to the F2806x header files to your project
Code Composer Studio 6.x:
To specify the directory where the header files are located:
Figure 2.4: Adding device header file directories to the include search path
6. Additional suggested build options The following are additional compiler and linker options.
The options can all be set via the Project-> Properties->Tool Settings sub-menus.
C2000 Compiler
• -ml Select Runtime Model Options and check -ml Build for large memory model.
This setting allows data sections to reside anywhere within the 4M-memory reach of
the 28x devices.
• -pdr Select Diagnostic Options and check -pdr Issue non-serious warnings. The
compiler uses a warning to indicate code that is valid but questionable. In many
cases, these warnings issued by enabling -pdr can alert you to code that may cause
problems later on.
C2000 Linker
• -w Select Diagnostics and check -w Warn about output sections. This option will
alert you if any unassigned memory sections exist in your code. By default the linker
will attempt to place any unassigned code or data section to an available memory
location without alerting the user. This can cause problems, however, when the section
is placed in an unexpected location.
• -e Select Symbol Management and enter Program Entry Point -e Defines a
global symbol that specifies the primary entry point for the output module. For the
F2806x examples, this is the symbol “code_start”. This symbol is defined in the
common\source\F2806x_CodeStartBranch.asm file. When you load the code in Code
Composer Studio, the debugger will set the PC to the address of this symbol. If you
do not define an entry point using the -e option, then the linker will use _c_int00 by
default.
#include "F2806x_Examples.h"
Another option is to #include “DSP28x_Project.h” in your source files, which in-turn includes
“F2806x_Cla_typedefs.h”,“F2806x_Device.h” and “F2806x_Examples.h”. Due to the device-
agnostic nature of the file name, user code is easily ported between different device header
files.
/********************************************************************
User’s source file
********************************************************************/
#include "DSP28x_Project.h"
2. Add the directory path to the example include files to your project. To specify the directory
where the header files are located:
Open the menu: Project->Properties.
In the menu on the left, select “C/C++ Build”.
In the “Tool Settings” tab, Select “C2000 Compiler -> Include Options:”
In the “Add dir to #include search path (–include_path, -I)” window, select the “Add” icon
in the top right corner.
Select the “File system...” button and navigate to the directory path of headers\include on
your system.
Figure 2.5: Adding Example header directories to the include search path
4. Set the CPU Frequency In the common\include\F2806x_Examples.h file specify the proper
CPU frequency. Some examples are included in the file.
/********************************************************************
common\include\F2806x_Examples.h
********************************************************************/
...
#define CPU_RATE 12.500L // for a 80MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 16.667L // for a 60MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 25.000L // for a 40MHz CPU clock speed (SYSCLKOUT)
...
5. Link desired common source files to the project The common source files are found in the
common\source directory.
6. Include .c files for the PIE Since all catalog 2806x applications make use of the PIE interrupt
block, you will want to include the PIE support .c files to help with initializing the PIE. The shell
ISR functions can be used directly or you can re-map your own function into the PIE vector
table provided. A list of these files can be found in section 2.8.2.1
Why do the examples populate the PIE vector table and then re-assign some of the
function pointers to other ISRs?
The examples share a common default ISR file. This file is used to populate the PIE vector
table with pointers to default interrupt service routines. Any ISR used within the example is
then remapped to a function within the same source file. This is done for the following reasons:
• The entire PIE vector table is enabled, even if the ISR is not used within the example. This
can be very useful for debug purposes.
• The default ISR file is left unmodified for use with other examples or your own project as
you see fit.
• It illustrates how the PIE table can be updated at a later time.
When I build the examples, the linker outputs the following: warning: entry point other
than _c_int00 specified. What does this mean?
This warning is given when a symbol other than _c_int00 is defined as the code entry point
of the project. For these examples, the symbol code_start is the first code that is executed
after exiting the boot ROM code and thus is defined as the entry point via the -e linker option.
This symbol is defined in the F2806x_CodeStartBranch.asm file. The entry point symbol is
used by the debugger and by the hex utility. When you load the code, CCS will set the PC to
the entry point symbol. By default, this is the _c_int00 symbol which marks the start of the C
initialization routine. For the F2806x examples, the code_start symbol is used instead. Refer
to the source code for more information.
When I build many of the examples, the compiler outputs the following: remark: con-
trolling expression is constant. What does this mean?
Some of the examples run forever until the user stops execution by using a while(1) loop. The
remark refers to the while loop using a constant and thus the loop will never be exited.
When I build some of the examples, the compiler outputs the following: warning: state-
ment is unreachable. What does this mean?
Some of the examples run forever until the user stops execution by using a while(1) loop. If
there is code after this while(1) loop then it will never be reached.
I changed the build configuration of one of the projects from “Debug” to “Release” and
now the project will not build. What could be wrong?
When you switch to a new build configuration (Project->Active Build Configuration) the com-
piler and linker options changed for the project. The user must enter other options such as
include search path and the library search path. Open the build options menu (Project-> Op-
tions) and enter the following information:
• C2000 Compiler, Include Options: Include search path
• C2000 Linker, File Search Path: Library search path
• C2000 Linker, File Search Path: Include libraries(i.e. rts2800_ml.lib)
Refer to section 2.5.3 for more details.
In the flash example I loaded the symbols and ran to main. I then set a breakpoint but
the breakpoint is never hit. What could be wrong?
In the Flash example, the InitFlash function and several of the ISR functions are copied out
of flash into SARAM. When you set a breakpoint in one of these functions, Code Composer
will insert an ESTOP0 instruction into the SARAM location. When the ESTOP0 instruction is
hit, program execution is halted. CCS will then remove the ESTOP0 and replace it with the
original opcode. In the case of the flash program, when one of these functions is copied from
Flash into SARAM, the ESTOP0 instruction is overwritten by code. This is why the breakpoint
is never hit. To avoid this, set the breakpoint after the SARAM functions have been copied to
SARAM.
1. Registers with multiple flag bits in which writing a 1 clears that flag
For example, consider the PIEACK register. Bits within this register are cleared when writing
a 1 to that bit. If more then one bit is set, performing a read-modify-write on the register may
clear more bits then intended.
The below solution is incorrect. It will write a 1 to any bit set and thus clear all of them:
/********************************************************************
User’s source file
********************************************************************/
The correct solution is to write a mask value to the register in which only the intended bit will
have a 1 written to it:
/********************************************************************
User’s source file
********************************************************************/
1. Create a copy of your project to work with or back-up your current project
Bit Name
Peripheral Register Old New Comment
XCLK Reserved(bit 6) XCLKINSEL(bit 6) On 2806x devices, XCLKIN can
SysCtrlRegs
be fed via a GPIO pin. This
bit selects either GPIO38 (de-
fault) or GPIO19 as XCLKIN in-
put source.
PLLSTS CLKINDIV(bit 1) DIVSEL (bits 8,7) DIVSEL allows more values by
which CLKIN can be divided.
Table 2.10: Summary of Register and Bit-Name Changes from DSP280x to F2806x
Additionally, unlike the DSP280x devices, the F2806x devices run off an internal oscillator (IN-
TOSC1) by default. To switch between the 2 available internal clock sources and the traditional
external oscillator clock source, a new register in the System Control register space - CLKCTL - is
available.
The files listed in Table 2.11 must be added to any project that uses the F2806x header files. Refer
to section 2.5 for information on incorporating the header files into a new or existing project.
2.8.1.2 F2806x Header Files - Peripheral Bit-Field and Register Structure Definition Files
The files listed in Table 2.12 define the bit-fields and register structures for each of the periph-
erals on the 2806x devices. These files are automatically included in the project by including
F2806x_Device.h. Refer to section 2.4.2 for more information on incorporating the header files
into a new or existing project.
File Description
F2806x_Adc.h ADC register structure and bit-field definitions.
F2806x_BootVars.h External boot variable definitions.
F2806x_Cla.h CLA register structure and bit-field definitions
F2806x_Comp.h Comparator register structure and bit-field definitions.
F2806x_CpuTimers.h CPU-Timer register structure and bit-field definitions.
F2806x_DevEmu.h Emulation register definitions
F2806x_Dma.h DMA register structure and bit-field definitions
F2806x_ECan.h eCAN register structures and bit-field definitions.
F2806x_ECap.h eCAP register structures and bit-field definitions.
F2806x_EPwm.h ePWM register structures and bit-field definitions.
F2806x_EQep.h eQEP register structures and bit-field definitions.
F2806x_Gpio.h General Purpose I/O (GPIO) register structures and bit-field def-
initions.
F2806x_HRCap.h High-Resolution Capture register structure and bit-field defini-
tions.
F2806x_I2c.h I2C register structure and bit-field definitions.
F2806x_Mcbsp.h McBSP register structures and bit-field definitions.
F2806x_NmiIntrupt.h NMI interrupt register structure and bit-field definitions
F2806x_PieCtrl.h PIE control register structure and bit-field definitions.
F2806x_PieVect.h Structure definition for the entire PIE vector table.
F2806x_Sci.h SCI register structure and bit-field definitions.
F2806x_Spi.h SPI register structure and bit-field definitions.
F2806x_SysCtrl.h System register definitions. Includes Watchdog, PLL, CSM,
Flash/OTP, Clock registers.
F2806x_Usb.h USB register structure and bit-field definitions.
F2806x_XIntrupt.h External interrupt register structure and bit-field definitions.
Table 2.12: F2806x Header File Bit-Field Register Structure Definition Files(headers\include)
This section is a summary of the variable names and data sections allocated by the head-
ers\source\F2806x_GlobalVariableDefs.c file as shown in Table 2.13. Note that all peripherals may
not be available on a particular 2806x device. Refer to the device datasheet for the peripheral mix
available on each 2806x family derivative.
In addition to the register definitions defined in F2806x_PieCtrl.h, this packet provides the basic
ISR structure for the PIE block. These files are shown in Table 2.14.
In addition, the files in Table 2.15 are included for software prioritizing of interrupts. These files are
used in place of those above when additional software prioritizing of the interrupts is required. Refer
to the example and documentation in examples\c28\sw_prioritized_interrupts for more information.
Table 2.15: Software Prioritized Interrupt PIE Block Specific Support Files
Several peripheral specific initialization routines and support functions are included in the peripheral
.c source files in the common\source directory. These files are shown in Table 2.16.
File Description
F2806x_GlobalPrototypes.h Function prototypes for the peripheral
specific functions included in these
files.
F2806x_Adc.c ADC specific functions and macros.
F2806x_Comp.c Comparator specific functions and
macros
F2806x_CpuTimers.c CPU-Timer specific functions and
macros.
F2806x_Dma.c DMA module specific functions and
macros
F2806x_Dma_defines.h define macros that are used for the
DMA examples
F2806x_ECan.c eCAN module specific functions and
macros
F2806x_ECap.c eCAP module specific functions and
macros.
F2806x_EPwm.c ePWM module specific functions and
macros.
F2806x_EPwm_defines.h define macros that are used for the
ePWM examples
F2806x_EQep.c eQEP module specific functions and
macros.
F2806x_Gpio.c General-purpose IO (GPIO) specific
functions and macros.
F2806x_HRCap.c High-Res Capture specific functions
and macros.
F2806x_I2C.c I2C specific functions and macros.
F2806x_I2c_defines.h define macros that are used for the I2C
examples
F2806x_Mcbsp.c McBSP specific functions and macros.
F2806x_PieCtrl.c PIE control specific functions and
macros.
F2806x_Sci.c SCI specific functions and macros.
F2806x_Spi.c SPI specific functions and macros.
F2806x_SysCtrl.c System control (watchdog, clock, PLL
etc) specific functions and macros.
NOTE: The specific routines are under development and may not all be available as of this
release. They will be added and distributed as more examples are developed.
File Description
F2806x_CodeStartBranch.asm Branch to the start of code execution.
This is used to re-direct code execu-
tion when booting to Flash, OTP or M0
SARAM memory. An option to disable
the watchdog before the C init routine
is included.
F2806x_DBGIER.asm Assembly function to manipulate the
DEBIER register from C.
F2806x_DisInt.asm Disable interrupt and restore interrupt
functions. These functions allow you
to disable INTM and DBGM and then
later restore their state.
F2806x_usDelay.asm Assembly function to insert a delay
time in microseconds. This function is
cycle dependent and must be executed
from zero wait-stated RAM to be accu-
rate. Refer to examples\c28\adc_soc
for an example of its use.
F2806x_CSMPasswords.asm Include in a project to program the
code security module passwords and
reserved locations.
Example memory linker command files are located in the common\cmd directory. For getting
started the basic 28069_RAM_lnk.cmd file is suggested and used by many of the included ex-
amples.
The L0 SARAM block is mirrored on these devices. For simplicity these memory maps only include
one instance of these memory blocks(Table 2.9).
Example library files are located in the C2000Ware_<version>\libraries\ directory. For this release
the IQMath library is included for use in the example projects. Please refer to the C28x IQMath
Library - A Virtual Floating Point Engine (SPRC087) for more information on IQMath and the most
recent IQMath library. The SFO libraries are also included for use in the example projects. Please
refer to TMS320x2802x, 2803x HRPWM Reference Guide (SPRUGE8) for more information on
SFO library usage and the HRPWM module(see Table 2.18).
V2.04.00.00
V2.03.00.00
V2.02.00.00
V2.01.00.00
V2.00.00.00
V1.51
V1.50
V1.41
V1.40
V1.36
V1.35
V1.30
V1.20
V1.15
V1.10
6. F2806x_Examples.h - added #defines for PLL2, added new part numbers for USB de-
vices.
7. F2806x_SWPrioritizedIsrLevels.h - added interrupts for HRCAP1,2,3,4 and USB0, cor-
rected code for Case1 and Case5.
8. IQmath.lib - removed library, library is located in \..\controlSUITE\libs.
9. F2806x_SWPrioritizedPieVect.c - added interrupts for HRCAP1,2,3,4 and USB0.
10. F2806x_SWPrioritizedDefaultIsr.c - added interrupts for HRCAP1,2,3,4 and USB0.
11. F2806x_SysCtrl.c - added code to enable HRCAP1,2,3,4 and USB0 clocks.
Changes to Example Files
1. Example_2806xAdcTempSensor.c - added code to set the ADC nonoverlap bit.
2. Example_2806xAdc_TempSensorConv.c - added code to set the ADC nonoverlap bit.
3. Example_2806xClaAdc.c - added code to set the ADC nonoverlap bit.
4. Example_2806xClaAdcFir.c - changed code to use ADCINA2, added code to set the
ADC nonoverlap bit.
5. Example_2806xClaAdcFirFlash.c - same changes as Example_F2806xClaAdcFir.c.
6. Example_2806xDMA_ram_to_ram.c - updated comments.
7. Example_2806xECanBack2Back.c - updated comments.
8. Example_2806xECap_apwm.c - updated to vary frequency on the PWM output, updated
comments.
9. Example_2806xEPwmDCEventTrip.c - updated comments.
10. Example_2806xEPwmDCEventTripComp.c - updated comments.
11. Example_2806xEPwmDeadBand.c - updated comments.
12. Example_2806xEPwmTripZone.c - updated comments.
13. Example_2806xExternalInterrupt.c - changed GPIOŠs to ones accessible on the 2806x
controlSTICK.
14. Example_2806xGpioSetup.c - updated comments, fixed code mistakes in GPIO10 and
GPIO34 setup.
15. Example_2806xGpioToggle.c - changed code so GPIO28 and GPIO29 do not toggle,
this was causing emulation failure.
16. Example_2806xHRPWM_Duty_SFO_V6.c - updated comments for 80 MHz, updated
comments for number of HRPWM channels.
17. Example_2806xHRPWM_MultiCh_PrdUpDown_SFO_V6.c - updated comments for 80
MHz.
18. Example_2806xHRPWM_PrdUp_SFO_V6.c - updated comments for 80 MHz.
19. Example_2806xHRPWM_PrdUpDown_SFO_V6.c - updated comments for 80 MHz.
20. Example_2806xI2C_eeprom.c - updated comment that referred to wrong ISR.
21. Example_2806xMcBSP_DLB_DMA.c - updated comment to match code on which DMA
accessible RAM section is used.
22. Example_2806xMcBSP_DLB_int.c - updated comments.
23. Example_2806xMcBSP_SPI_DLB.c - updated comments, removed unused variable.
24. Example_2806xOscComp.c - changed comment to match code setting xclkout, added
ADC nonoverlap bit, changed sampling window of ADC, removed code to sample ADC
twice.
25. Example_2806xSci_Echoback.c - fixed code error with SCIHBAUD and SCILBAUD reg-
isters, eliminated repetitive line of code.
26. Example_2806xScia_FFDLB.c - updated comments.
27. Example_2806xSci_FFDLB_int.c - updated comments.
V1.00
This version is the first release (packaged with development tools and customer trainings) of
the F2806x header files and examples.
3.1 Introduction
This chapter aims to give you, the user, a step by step guide on how to create and debug projects
from scratch. This guide will focus on the user of a Piccolo controlCARD, but these same ideas
should apply to other boards with minimal translation.
1. From the main CCS window select File -> New -> CCS Project. Name your project , select
the output type (Executable), set the location of the project. Device Family should be selected
to C2000. Ensure that your window matches the settings below except for perhaps the device
variant. After you are satisfied with these settings select Finish and your project will be created.
2. Click on Advanced settings to expand it and alter the desired Compiler Version and Runtime
Support library.
3. Before we can successfully build a project we need to setup some build spe-
cific settings. Right click on your project and select Build Properties. In the
Tool Settings tab look for and select the Include Options. Click on the add di-
rectory icon to add a directory to the search path. Click the File System button
to browse to the common\include folder of your C2000ware installation (typically
C:\TI\c2000\C2000ware_<version>\device_support\f2806x\common\include).
Click ok to add this path, and repeat this same process to add the headers\include
directory.
While you have this window open select the Symbol Management options under C2000 Linker.
Specify the program entry point to be code_start. Select ok to close out of the Build Prop-
erties.
4. Next we need to link in a few files which are used by the header files. To do this right click
on your project in the workspace and select Link Files... Navigate to the headers\source
directory, and select F2806x_GlobalVariableDefs.c. Link in the following files as well:
headers\cmd\F2806x_Headers_nonBIOS.cmd
common\source\F2806x_CodeStartBranch.asm
common\source\F2806x_usDelay.asm
common\cmd\28069_RAM_CLA_lnk.cmd or another appropriate linker command file
At this point your project workspace should look like the following:
In this step we linked a file to the project which only created a symbolic link in the project to
the actual file in the hard drive. This means that if you modify a linked file in CCS you are
modifying the original file in C2000ware. We won’t be modifying the linker command file or
header files, so this is ok.
5. Create a new file by right clicking on the project and selecting New -> File. Name this file
main.c and copy the following code into it:
#include "DSP28x_Project.h"
void main(void)
{
//
// Disable Protection
//
EALLOW;
//
// Make Port B GPIOs outputs
//
GpioCtrlRegs.GPADIR.all = 0x0000FF00;
while(1)
{
//
// Toggle GPIOs 8-15
//
GpioDataRegs.GPADAT.all = 0x0000FF00;
DELAY_US(100);
GpioDataRegs.GPADAT.all = 0x00000000;
DELAY_US(100);
}
}
6. Save main.c and then build the project by right clicking on it and selecting Build Project. You
have just built your first Piccolo project from scratch.
5. Import the desired example projects (or skip this step if you are using projects you created
in the Project Creation section). Click File -> Import, and in the CCS folder select Existing
CCS Eclipse Projects before clicking Next. With the "Select search-directory" radio button
checked, browse to the root of your C2000ware installation. Device specific software as well
as examples are stored in the device_support/device_variant folders. Navigate to the
f2806x directory, and then to the examples\c28 directory. Click OK and CCS will parse all
of the projects in this directory. Import any projects you wish to run into the workspace. Do not
select "Copy projects into workspace". These projects use relative paths to link to external
resouces, so taking them out of C2000ware will break the project.
6. Build each of the example projects. Right click on each project title and select build project.
7. Launch the previously created target configuration. Click View -> Target Configurations. In the
window that opens, find the desired target configuration, right click on it and select "Launch
Target Configuration".
8. Connect to the device. Right click on each core in the debug window and select "Connect
Target. This will connect CCS to the device and will allow you to load code and debug appli-
cations.
9. Load code onto the device. Select the C28x session in the debug window and then click Target
-> Load Program. A dialog box is displayed which will allow you to select a program to load.
10. At this point the C28 should have code loaded and be halted at main. From this point, users
should be able to debug code. Please keep in mind that any action you take in CCS only has
an effect on the session you currently have selected in the debug window. For instance if the
C28 is selected, the register view will display the registers of the C28 system. The opposite
would be true if the CLA were selected.
3.4 Troubleshooting
There are a number of things that can cause the user trouble while bringing up a debug session
the first time. This section will try to provide solutions to the most common problems encountered
with the Concerto devices.
"I get a managed make error when I import the example projects"
This occurs when one imports a project for which he or she doesn’t have the code generation tools
for. Please ensure that you have at least version 6.0.1 of the C2000 Code Generation Tools.
"I cannot build the example projects"
This is caused by linked resources not being where the project expects them to be. For instance, if
you imported the projects and selected "Copy projects to workspace", the projects would no longer
build because the files they refernce aren’t a part of your workspace. Always build and run the
examples directly in the C2000ware tree.
"I cannot connect to the target"
This is most often times caused by either a bad target configuration, or simply the emulator being
physically disconnected. If you are unable to connect to a target check the following things:
1. Ensure the target configuration is correct for the device you have.
2. Ensure the emulator is plugged in to both the computer and the device to be debugged.
3. Ensure that the target device is powered.
We have provided scripts to automate setting up watch variables and associated graphs called
’SetupDebugEnv.js’ in several example folders. Once you have established a connection to the
target device in debug mode go to View->Scripting Console. Within the console click the Open
Command file icon in the far right corner of the console window and select the javascript file.
All of these examples reside in the examples\c28 subdirectory of the C2000Ware package.
Examples for the CLA ’C’ compiler are in the examples\cla subdirectory
Note:
THIS EXAMPLE USES VARIABLES STORED IN OTP DURING FACTORY TEST. THESE OTP
LOCATIONS ,0x3D7E90 to 0x3D7EA4, MAY NOT BE POPULATED. ENSURE THAT THESE
MEMORY LOCATIONS IN TI OTP ARE POPULATED WITH VALUES DIFFERENT FROM
0XFFFF
Watch Variables
temp
degC
degK
This example application is used in conjunction with the USB boot loader (boot_usb) and turns the
evaluation board into a composite device supporting a mouse via the Human Interface Device class
and also publishing runtime Device Firmware Upgrade (DFU) capability. Dragging a finger or stylus
over the touchscreen translates into mouse movement and presses on marked areas at the bottom
of the screen indicate mouse button press. This input is used to generate messages in HID reports
sent to the USB host allowing the evaluation board to control the mouse pointer on the host system.
Since the device also publishes a DFU interface, host software such as the dfuprog tool can deter-
mine that the device is capable of receiving software updates over USB. The runtime DFU protocol
allows such tools to signal the device to switch into DFU mode and prepare to receive a new soft-
ware image.
Runtime DFU functionality requires only that the device listen for a particular request (DETACH)
from the host and, when this is received, transfer control to the USB boot loader via the normal
means to reenumerate as a pure DFU device capable of uploading and downloading firmware
images.
Windows device drivers for both the runtime and DFU mode of operation can be found in
C:/StellarisWare/windows_drivers assuming you installed StellarisWare in the default di-
rectory.
To illustrate runtime DFU capability, use the dfuprog tool which is part of the Stellaris Win-
dows USB Examples package (SW-USB-win-xxxx.msi) Assuming this package is installed in
the default location, the dfuprog executable can be found in the C:/Program Files/Texas
Instruments/Stellaris/usb_examples directory.
With the device connected to your PC and the device driver installed, enter the following command
to enumerate DFU devices:
dfuprog -e
This will list all DFU-capable devices found and you should see that you have one device available
which is in “Runtime” mode. Entering the following command will switch this device into DFU mode
and leave it ready to receive a new firmware image:
dfuprog -m
After entering this command, you should notice that the device disconnects from the USB bus and
reconnects again. Running “dfuprog -e” a second time will show that the device is now in DFU
mode and ready to receive downloads. At this point, either LM Flash Programmer or dfuprog may
be used to send a new application binary to the device.
Watch Variables
Watch Variables
CpuTimer0.InterruptCount
CpuTimer1.InterruptCount
CpuTimer2.InterruptCount
PassCount
ErrorCount
MessageReceivedCount
Up count
Period starts at 2 and goes up to 1000
Toggle output on PRD
eCAP1 is configured to capture the time between rising and falling edge of the ePWM3A output.
External Connections
eCAP1 is on GPIO5
ePWM3A is on GPIO4
Connect GPIO4 to GPIO5
Watch Variables
ePWM1: DCAEVT1 forces EPWM1A high, a blanking window is used EPWM1B toggles on
zero as a reference.
ePWM2: DCAEVT1 forces EPWM2A high, no blanking window is used EPWM2B toggles on
zero as a reference. ePWM1A is set to normally stay low. DCAEVT1 is true when TZ1 is
low and TZ2 is high. When an event is true (DCAEVT1) EPWM1A is configured to be forced
high. A blanking window is applied to keep the event from taking effect around the zero point.
In other words, when the event is taken, EPWM1A will be forced high if there is no event,
EPWM1A will remain low. Notice the blanking window keeps the event from forcing EPWM1A
high around the zero point. ePWM2 is configured the same way as ePWM1 except no blanking
window is applied.
Initially tie TZ1 (GPIO12) and TZ2 (GPIO13) high. During the test, monitor ePWM1 or ePWM2
outputs on a scope. Create DCAEVT1 by pulling TZ1 low and TZ2 high to see the effect.
External Connections
ePWM1A is on GPIO0
ePWM1B is on GPIO1
ePWM2A is on GPIO2
ePWM2B is on GPIO3
TZ1 is on GPIO12
TZ2 is on GPIO13
ePWM1 has DCAEVT1 as a one shot trip source The trip event will pull ePWM1A high The
trip event will pull ePWM1B low
ePWM2 has DCAEVT2 as a cycle by cycle trip source The trip event will pull ePWM2A high
The trip event will pull ePWM2B low
ePWM3 reacts to DCAEVT2 and DCBEVT1 events The DCAEVT2 event will pull ePWM3A
high The DCBEVT1 event will pull ePWM3B low
Initially tie TZ1 (GPIO12) and TZ2 (GPIO13) high. During the test, monitor ePWM1 or ePWM2
outputs on a scope pull TZ1 low and leave TZ2 high to create a DCAEVT1, DCAEVT2, DCBEVT1
and DCBEVT2. View the EPWM1A/B, EPWM2A/B, EPWM3A/B waveforms on an oscilloscope to
see the effect of the events.
External Connections
EPWM1A is on GPIO0
EPWM1B is on GPIO1
EPWM2A is on GPIO2
EPWM2B is on GPIO3
EPWM3A is on GPIO4
EPWM3B is on GPIO5
TZ1 is on GPIO12
TZ2 is on GPIO13
pull TZ1 low and leave TZ2 high to create a DCAEVT1, DCAEVT2, DCBEVT1 and DCBEVT2.
ePWM1 has DCAEVT1 and DCBEVT1 as one shot trip sources DCAEVT1 will pull EPWM1A
high DCBEVT1 will pull EPWM1B low
Initially make the voltage level at COMP1A to be higher than that of COMP1B. Increase voltage
on inverting side of comparator(COMP1B pin) to trigger a DCAEVT1, and DCBEVT1. ePWM1
will react to DCAEVT1 and DCBEVT1 as a 1 shot trip. View the EPWM1A/B waveforms on an
oscilloscope to see the effect of the events.
External Connections
EPWM1A is on GPIO0
EPWM1B is on GPIO1
COMP1A is on ADCA2
COMP1B is on ADCB2
pull COMP1B to a higher voltage level than COMP1A.
Count up/down
Deadband 3 Examples are included:
ePWM1: Active low PWMs
ePWM2: Active low complementary PWMs
ePWM3: Active high complementary PWMs
Each ePWM is configured to interrupt on the 3rd zero event when this happens the deadband is
modified such that 0 <= DB <= DB_MAX. That is, the deadband will move up and down between
0 and the maximum value.
External Connections
EPWM1A is on GPIO0
EPWM1B is on GPIO1
EPWM2A is on GPIO2
EPWM2B is on GPIO3
EPWM3A is on GPIO4
EPWM3B is on GPIO5
ePWM1 is initialized
ePWM1 is cleared at period match and set at Compare-A match
Compare A match occurs at half period
GPIOs for LED2 and LED3 are initialized
Free_Soft bits and DBGIER are cleared
An interrupt is taken on a zero event for the ePWM1 timer
Watch Variables
EPwm1TimerIntCount
EPwm1Regs.TBCTL.bit.FREE_SOFT
EPwm1Regs.TBCTR
DBGIER.INT3
Watch Variables
EPwm1TimerIntCount
EPwm2TimerIntCount
EPwm3TimerIntCount
EPwm4TimerIntCount
Initially tie TZ1 and TZ2 high. During the test, monitor ePWM1 or ePWM2 outputs on a scope. Pull
TZ1 or TZ2 low to see the effect.
External Connections
EPWM1A is on GPIO0
EPWM1B is on GPIO1
EPWM2A is on GPIO2
EPWM2B is on GPIO3
TZ1 is on GPIO12
TZ2 is on GPIO13
EPWM1A is on GPIO0
EPWM1B is on GPIO1
EPWM2A is on GPIO2
EPWM2B is on GPIO3
EPWM3A is on GPIO4
EPWM3B is on GPIO5
External Connections
EPWM1A is on GPIO0
EPWM1B is on GPIO1
EPWM2A is on GPIO2
EPWM2B is on GPIO3
EPWM3A is on GPIO4
EPWM3B is on GPIO5
See also:
section on Frequency Calculation for more details on the frequency calculation performed in
this example.
In addition to the main example file, the following files must be included in this project:
SPEED_FR: High Frequency Measurement is obtained by counting the external input pulses for
10ms (unit timer set to 100Hz).
Count Delta
SP EED_F R =
10ms
SPEED_PR: Low Frequency Measurement is obtained by measuring time period of input edges.
Time measurement is averaged over 64edges for better results and capture unit performs the time
measurement using pre-scaled SYSCLK
Note that pre-scaler for capture unit clock is selected such that capture timer does not overflow at
the required minimum frequency This example runs forever until the user stops it.
External Connections
Connect GPIO20/EQEP1A to GPIO0/EPWM1A
Watch Variables
Note:
2 x2 −x1
T = 100Hz . 2 is from 2 because QPOSCNT counts 2 edges per cycle (rising and falling)
x2 − x1
1=
10kHz ∗ (2/100Hz)
where,
2
[10kHz ∗ ] = 200
100Hz
Because
x2 − x1 < 200(max)
x2 − x1
<1
200
for all frequencies less than max
x2 − x1 x2 − x1
f req_f r = or ..........3
200 10kHz ∗ (2/100Hz)
x2 − x1
f reqhz_f r(or velocity) = 10kHz ∗
10kHz ∗ (2/100Hz)
x2 − x1
= ..........f inal equation
(2/100Hz)
1 count
1. ∗∗min freq∗∗ = (2/100Hz) = 50Hz
2. ∗∗freqhz_pr∗∗
X
f reqhz_pr or v = ..........4
t2 − t1
If
max (8/2) 8
f req = 10kHz => 10kHz = =
base T 2T
where,
8 = QCAPCTL [UPPS] (Unit timeout - once every 8 edges)
2 = divide by 2 because QPOSCNT counts 2 edges per cycle (rising and falling)
t2 −t1
T = time in seconds = (100M Hz/128) , t2 − t1 = # of QCAPCLK cycles,
1
and 1 QCAP CLK cycle = (100M Hz/128) = QCP RDLAT
So:
(90M Hz/128)
10kHz = 8 ∗
2 ∗ (t2 − t1 )
250
Because (t2 − t1 ) < 250(max), t2 −t1 < 1 for all frequencies less than max
Now within velocity limits, to get back to original velocity equation, Equation 1, multiply Equation 6
by 10 kHz:
(90M Hz/128) ∗ 8
=
2 ∗ (t2 − t1 )
or
8
..........f inal equation
2 ∗ (t2 − t1 ) ∗ (QCP RDLAT )
More detailed calculation results can be found in the Example_freqcal.xls spreadsheet included in
the example folder.
Note:
External Connections
Watch Variables
Watch Variables
Steps that were taken to convert the ePWM example from RAM to Flash execution:
Change the linker cmd file to reflect the flash memory map.
Make sure any initialized sections are mapped to Flash. In SDFlash utility this can be checked
by the View->Coff/Hex status utility. Any section marked as "load" should be allocated to
Flash.
Make sure there is a branch instruction from the entry to Flash at 0x3F7FF6 to the beginning
of code execution. This example uses the DSP0x_CodeStartBranch.asm file to accomplish
this.
Set boot mode Jumpers to "boot to Flash"
For best performance from the flash, modify the waitstates and enable the flash pipeline as
shown in this example. Note: any code that manipulates the flash waitstate and pipeline
control must be run from RAM. Thus these functions are located in their own memory section
called ramfuncs.
Watch Variables
EPwm1TimerIntCount
EPwm2TimerIntCount
EPwm3TimerIntCount
The required software setup before calling the API (setting the PLL, checking for limp mode
etc.),
How to copy the API from flash into SARAM for execution.
How to call the API functions.
NOTE This example runs from Flash. First program the example into flash. The code will then copy
the API’s to RAM and modify the flash.
Watch Variables:
Watch Variables:
All pullup resistors are enabled. For ePWMs this may not be desired.
Input qual for communication ports (eCAN, SPI, SCI, I2C) is asynchronous
Input qual for Trip pins (TZ) is asynchronous
Input qual for eCAP and eQEP signals is synch to SYSCLKOUT
Input qual for some I/O’s and interrupts may have a sampling window
Three different examples are included. Select the example (data, set/clear or toggle) to execute
before compiling using the macros found at the top of the code.
Each example toggles all the GPIOs in a different way, the first through writing values to the GPIO
DATA registers, the second through the SET/CLEAR registers and finally the last through the TOG-
GLE register
The pins can be observed using Oscilloscope.
To measure high pulse width or low pulse width, user must set: #define PERIODTEST 0
width pulsewidthlow
To determine the actual pulse period time in pulsewidthhigh period:
pulsewidthinseconds = pulsewidth[n] ∗ (1HCCAP CLKcycle)
(i.e. 1 HCCAPCLK cycle is 8.33 ns for 120 MHz HCCAPCLK)
PLL2 is configured such that:
Because there is no EMU FREE/STOP support in the HRCAP peripheral, the HRCAP results
cannot easily be seen in "Real-time continuous refresh" debug mode. The only way to see
accurate results of the capture is to set a breakpoint in the HRCAP ISR immediately after
data has been captured. Otherwise the results read at any other time in the program via the
debugger could be mid-capture between one period and the next, and therefore bogus.
External Connections
HRCAP1 is on GPIO27
ePWM1A is on GPIO0
Connect output of ePWM1A to input of HRCAP1 (GPIO0->GPIO27)
Watch Variables
pulsewidthlow
• Pulse Width of Low Pulses (# of HCCAPCLK cycles - int + frac) in Q16 format (i.e. upper
16-bits integer, lower 16-bits fraction)
pulsewidthhigh
• Pulse Width of High Pulses (# of HCCAPCLK cycles - int + frac) in Q16 format (i.e. upper
16-bits integer, lower 16-bits fraction)
periodwidth
• Period Width (# of HCCAPCLK cycles - int + frac) in Q16 format (i.e. upper 16-bits integer,
lower 16-bits fraction)
Up count
Period starts at 100 and goes up to 4000 then back down again.
Toggle output on PRD PLL2 is configured such that:
PLL2 = 60 MHz using INTOSC1 (10 MHz) as source
HCCAPCLK = 120 MHz
Note:
On Piccolo-B, the HCCAPCLK frequency is 2 ∗ SYSCLK.EPWM period in up-count mode
is TBPRD + 1 SYSCLK counts. Therefore,
eP W M period(up count mode) = 2 ∗ (T BP RD + 1)HCCAP CLK counts
Because there is no EMU FREE/STOP support in the HRCAP peripheral, the HRCAP
results cannot easily be seen in "Real-time continuous refresh" debug mode. The only way
to see accurate results of the capture is to set a breakpoint in the HRCAP ISR immediately
after data has been captured. Otherwise the results read at any other time in the program
via the debugger could be mid-capture between one period and the next, and therefore
bogus.
CLK _F REQ
PULSEHIGH = (U int32)(EP wm1Regs.T BP RD + 1) ∗ ( HCCAP SY SCLK _F REQ ) −
P W M U pcountperiodinHCSY N CCLKcounts
= TBPRD + 1 SYSCLK counts
CLK _F REQ
=(TBPRD + 1)∗( HCCAP
SY SCLK _F REQ ) HCCAPCLK counts
The (HCCAPCLK_FREQ/SYSCLK_FREQ) ratio represents the number of of HCCAPCLK
cycles in 1 SYSCLK cycle
External Connections
HRCAP2 is on GPIO27
ePWM1A is on GPIO0
Connect output of ePWM1A to input of HRCAP2 (GPIO0->GPIO27)
Watch Variables
PULSELOW
• Pulse Width of Low Pulses (# of HCCAPCLK cycles - integer)
PULSEHIGH
• Pulse Width of High Pulses (# of HCCAPCLK cycles - integer)
External Connections
Monitor ePWM1-ePWM4 pins on an oscilloscope as described below:
ePWM1A is on GPIO0
ePWM1B is on GPIO1
ePWM2A is on GPIO2
ePWM2B is on GPIO3
ePWM3A is on GPIO4
ePWM3B is on GPIO5
ePWM4A is on GPIO6
ePWM4B is on GPIO7
This example is intended to explain the HRPWM capabilities. The code can be optimized for code
efficiency. Refer to TI’s Digital power application examples and TI Digital Power Supply software
libraries for details. All ePWM1A-7A channels will have fine edge movement due to the HRPWM
logic
Note:
This program requires the F2806x header files, which include the following files required
for this example: SFO_V6.h and SFO_TI_Build_V6.lib
For more information on using the SFO software library, see the 2803x High-Resolution
Pulse Width Modulator (HRPWM) Reference Guide
External Connections
Monitor ePWM1A-ePWM4A (GPIO0-GPIO7) pins on an oscilloscope.
Running the Application
Watch Variables
UpdateFine
• Set the variable UpdateFine = 1 to observe the ePWMxA output with HRPWM capabilities
(default) Observe the duty cycle of the waveform change in fine MEP steps
• Change the variable UpdateFine to 0, to observe the ePWMxA output without HRPWM
capabilities Observe the duty cycle of the waveform change in coarse SYSCLKOUT cycle
steps.
updates HRMSTEP register (exists only in EPwm1Regs register space but valid for all chan-
nels) with MEP_ScaleFactor value
Returns
• 2 if error: MEP_ScaleFactor is greater than maximum value of 255 (Auto-conversion may
not function properly under this condition)
• 1 when complete for the specified channel
• 0 if not complete for the specified channel
All ePWM1A-4A channels will be synchronized to each other (with ePWM1 sync’d to the SWF-
SYNC) and have fine edge period movement due to the HRPWM logic. This example can be used
as a primitive building block for applications which require high resolution frequency control with
synchronized ePWM modules (i.e. resonant converter applications)
Note:
This program requires the F2806x header files, which include the following files required
for this example: SFO_V6.h and SFO_TI_Build_V6.lib
For more information on using the SFO software library, see the High-Resolution Pulse
Width Modulator (HRPWM) section of the Technical Reference Manual
External Connections
Monitor ePWM1A-ePWM4A (GPIO0-GPIO7) pins on an oscilloscope.
Running the Application
Watch Variables
UpdateFine
• Set the variable UpdateFine = 1 to observe the ePWMxA output with HRPWM capabilities
(default) Observe the period/frequency of the waveform changes in fine MEP steps
• Change the variable UpdateFine to 0, to observe the ePWMxA output without HRPWM
capabilities
UpdateCoarse
• To change the period/frequency in coarse steps, uncomment the relevant code, re-build
and re-run with UpdateCoarse = 1. Observe the period/frequency of the waveform
changes in coarse SYSCLKOUT cycle steps.
This example is intended to explain the HRPWM capabilities. The code can be optimized for code
efficiency. Refer to TI’s Digital power application examples and TI Digital Power Supply software
libraries for details. All ePWM1A-7A channels will have fine edge movement due to the HRPWM
logic
Note:
This program requires the F2806x header files, which include the following files required
for this example: SFO_V6.h and SFO_TI_Build_V6.lib
For more information on using the SFO software library, see the High-Resolution Pulse
Width Modulator (HRPWM) section of the Technical Reference Manual
External Connections
Monitor ePWM1A-ePWM4A (GPIO0-GPIO7) pins on an oscilloscope.
Running the Application
Watch Variables
UpdateFine
• Set the variable UpdateFine = 1 to observe the ePWMxA output with HRPWM capabilities
(default) Observe the period/frequency of the waveform changes in fine MEP steps
• Change the variable UpdateFine to 0, to observe the ePWMxA output without HRPWM ca-
pabilities Observe the period/frequency of the waveform changes in coarse SYSCLKOUT
cycle steps.
This example is intended to explain the HRPWM configuration for high resolution period/frequency.
The code can be optimized for code efficiency. Refer to TI’s Digital power application examples
and TI Digital Power Supply software libraries for details. ePWM1A (GPIO0) will have fine edge
movement due to the HRPWM logic
Note:
This program requires the F2806x header files, which include the following files required
for this example: SFO_V6.h and SFO_TI_Build_V6.lib
For more information on using the SFO software library, see the High-Resolution Pulse
Width Modulator (HRPWM) section of the Technical Reference Manual
External Connections
Monitor ePWM1A (GPIO0) pin on an oscilloscope.
Running the Application
1. ∗∗!!IMPORTANT!!∗∗ : in SFO_V6.h, set PWM_CH to the max used HRPWM channel plus one.
For example, for the F2803x, the maximum number of HRPWM channels is 7. 7+1=8, so set
#define PWM_CH 8 in SFO_V6.h. (Default is 5)
2. For this specific example, you could set #define PWM_CH 2 (because it only uses ePWM1),
but to cover all examples, PWM_CH is currently set to a default value of 5.
3. Load the code and add the watch variables to the watch window. See below for a list of watch
variables
4. Run this example at maximum SYSCLKOUT (80 MHz)
5. Activate Real time mode
Watch Variables
UpdateFine
• Set the variable UpdateFine = 1 to observe the ePWMxA output with HRPWM capabilities
(default) Observe the period/frequency of the waveform changes in fine MEP steps
• Change the variable UpdateFine to 0, to observe the ePWMxA output without HRPWM ca-
pabilities Observe the period/frequency of the waveform changes in coarse SYSCLKOUT
cycle steps.
PeriodFine
EPwm1Regs.TBPRD
EPwm1Regs.TBPRDHR
ePWM1A is on GPIO0
ePWM1B is on GPIO1
ePWM2A is on GPIO2
ePWM2B is on GPIO3
ePWM3A is on GPIO4
ePWM3B is on GPIO5
SY SCLK
(b) P W M F req = period=20
ePWM2A toggle low/high with MEP control on rising edge
SY SCLK
P W M F req = period=20
ePWM2B toggle low/high with NO HRPWM control
SY SCLK
(c) P W M F req = period=10
ePWM3A toggle as high/low with MEP control on falling edge
SY SCLK
P W M F req = period=10
ePWM3B toggle low/high with NO HRPWM control
SY SCLK
(d) P W M F req = period=20
ePWM4A toggle as high/low with MEP control on falling edge
SY SCLK
P W M F req = period=20
ePWM4B toggle low/high with NO HRPWM control
Watch Variables
DutyFine
Channels ePWM1A and ePWM2A will have fine edge movement due to the HRPWM logic when
the duty cycle is altered. Channels ePWM1B and ePWM2B have a fixed 50% duty cycle.
Note:
This program requires the F2806x header files, which include the following files required
for this example: SFO_V6.h and SFO_TI_Build_V6.lib
For more information on using the SFO software library, see the F2806x High-Resolution
Pulse Width Modulator (HRPWM) Reference Guide
External Connections
Monitor ePWM1A, ePWM1B, ePWM2A and ePWM2B (GPIO0-GPIO3) pins on an oscilloscope.
Note:
This program will only work on kits that have an on-board I2C EEPROM.
Watch Variables
I2cMsgIn1
I2cMsgOut1
The data written to the EEPROM is contained in the TX message buffer, TxMsgBuffer. The data
read back will be contained in the RX message buffer, RxMsgBuffer.
Note:
This program will only work if an external I2C EEPROM is properly connected to the device’s
I2C SDA/SCL signals.
Watch Variables
TxMsgBuffer
RxMsgBuffer
Note:
This program will only work if an external I2C EEPROM is properly connected to the device’s
I2C SDA/SCL signals.
Watch Variables
TxMsgBuffer
RxMsgBuffer
from STANDBY mode when a low pulse (signal goes high->low->high)is detected on the pin. This
pin must be pulsed by an external agent for wakeup.
As soon as GPIO0 goes high again after the pulse, the device should wake up, and GPIO1 can be
observed to toggle.
External Connections
To observe when device wakes from STANDBY mode, monitor GPIO1 with an oscilloscope (set to
1 in WAKEINT ISR)
Note:
sdata2 and rdata2 are not used for 8-bit or 16-bit word size
By default for the McBSP examples, the McBSP sample rate generator (SRG) input clock frequency
is LSPCLK 80E6/4.
Watch Variables:
EXAMPLE1 captures the clock fail in the ISR and then re-enables the INTOSC before returning
to the application (No device reset)
EXAMPLE2 captures the clock fail in the ISR and waits for the device to reset. IMPORTANT
make sure to configure emulation boot mode to "boot to RAM". This can be done via GEL
script (In CCS, go to Scripts->EMU Boot Mode Select->EMU_BOOT_SARAM)
Note:
This program makes use of variables stored in OTP during factory test on 2806x TMS
devices.
These OTP locations on pre-TMS devices may not be populated. Ensure that the following
memory locations in TI OTP are populated (not 0xFFFF) before use:
• 0x3D7E90 to 0x3D7EA4
Watch Variables
temp
SysCtrlRegs.INTOSC1TRIM
SysCtrlRegs.INTOSC2TRIM
1. Configure hyperterminal: Use the included hyperterminal configuration file SCI_96.ht. To load
this configuration in hyperterminal
(a) Open hyperterminal
(b) Go to file->open
(c) Browse to the location of the project and select the SCI_96.ht file.
2. Check the COM port. The configuration file is currently setup for COM1. If this is not correct,
disconnect (Call->Disconnect) Open the File-Properties dialog and select the correct COM
port.
3. Connect hyperterminal Call->Call and then start the 2806x SCI echoback program execution.
4. The program will print out a greeting and then ask you to enter a character which it will echo
back to hyperterminal.
Note:
If you are unable to open the .ht file, you can create a new one with the following settings
Find correct COM port
Bits per second = 9600
Date Bits = 8
Parity = None
Stop Bits = 1
Hardware Control = None
Watch Variables
External Connections
Connect the SCI-A port to a PC via a transceiver and cable.
rdata_pointA ,Keep track of where we are in the datastream. This is used to check the
incoming data
1. Before compiling you must set the Global and Group interrupt priorities in the
F2806x_SWPrioritizedIsrLevels.h file.
2. Select which test case you’d like to run with the #define CASE directive (1-9, default 1).
3. Compile the code, load, and run
4. At the end of each test there is a hard coded breakpoint (ESTOP0). When code stops at the
breakpoint, examine the ISRTrace buffer to see the order in which the ISR’s completed. All
PIE interrupts will be added to the ISRTrace. The ISRTrace will consist of a list of hex values
as shown:
0x00wx <- PIE Group w interrupt x finished first
0x00yz <- PIE Group y interrupt z finished next
5. If desired, set a new set of Global and Group interrupt priorities and repeat the test to see the
change.
Watch Variables
ISRTrace , Trace of ISR’s in the order they complete. After each test, examine this buffer to
determine if the ISR’s completed in the order desired.
CpuTimer0.InterruptCount
External Connections
Monitor the GPIO34 LED blink on (for 500 msec) and off (for 500 msec) on the 2806x control card.
The user can select to feed the watchdog key register or not by commenting the following line of
code in the infinite loop: ServiceDog();
If the watchdog key register is fed by the ServiceDog function then the WAKEINT interrupt is not
taken. If the key register is not fed by the ServiceDog function then WAKEINT will be taken.
Watch Variables
5 CLA C Compiler
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Getting Started with the CLA Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Known Debugging Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
5.1 Introduction
The goal of the CLA compiler is to implement enough of the C programming environment to make
it easier to access the capabilities of the CLA architecture and to make it easier to integrate CLA
task code and data into a C28x application.
The purpose of testing the prototype is to:
The compiler is available on the Tools download page, CLA Beta Tools , along with each revision’s
README and defect history. Template projects that were part of the regression tests are now
incorporated in the examples\cla folder
All bugs, performance issues should be reported to Compiler Support, either at the forum Compiler
Forum or ClearQuest Report
5.2 Overview
The README.txt file included in the compiler download package contains the latest details on the
CLA compiler’s C language implementation and it is highly recommended that you go over this
document before you begin coding.
N OTE : T HE COMPILER DOES NOT SUPPORT COMPILING BOTH CLA AND C28 X C FILES IN ONE
INVOCATION .
Language
Data Types
char,short - 16 bits
int,long - 32 bits (’long long’ data type is not supported)
float, double, long double - 32 bits
pointers - 16 bits
IMPORTANT NOTES:
NOTE!! THE CLA COMPILER DOES NOT HAVE 64-BIT TYPE SUPPORT.
Pragmas
C Standard Library
In general, the C standard library is not supported. abs() and fabs() are supported as intrinsics. An
inline fast floating-point divide is supported.
Keywords
Intrinsics
float __meisqrtf32(float)
float __meinvf32(float)
float __mminf32(float, float)
float __mmaxf32(float, float)
void __mswapf(float, float)
short __mf32toi16r(float)
unsigned short __mf32toui16r(float)
float __mfracf32(float)
__mdebugstop()
__meallow()
__medis()
__msetflg(unsigned short, unsigned short)
__mnop()
Stack
Local variables and compiler temps are placed into a scratchpad memory area and accessed di-
rectly using the symbols ’__cla_scratchpad_start’ and ’__cla_scratchpad_end’. It is expected
that the user will manage this area and define these symbols using a linker command file.
IMPORTANT NOTES:
Local variables and compiler temps are expected to be placed into a scratchpad
memory area and accessed directly using the symbols ’__cla_scratchpad_start’
and ’__cla_scratchpad_end’.
• It is expected that the user will manage this area and define
these symbols using a linker command file.
• This scratchpad serves as a CLA stack.
To allow debug of local variables, the linker .cmd file has been updated
from that originally distributed
• Please ensure the changes to the .cmd file shown below are made
before proceeding.
• The linker file should look like the code shown below.
• This also required a compiler released after July 21, 2011.
The following is an example of what needs to be added to a linker command file to define the CLA
compiler scratchpad memory:
Define the scratchpad size - CLA_SCRATCHPAD_SIZE is a linker defined symbol that can
added to the application’s linker command file to designate the size of the scratchpad memory.
A SECTION’s directive can reference this symbol to allocate the scratchpad area. This direc-
tive reserves a 0x100 word memory hole to be used as the compiler scratchpad area.
The scratchpad area is named CLAscratch and is allotted to CLA Data RAM 1 (CLARAM1)
The value of CLA_SCRATCHPAD_SIZE can be changed based on the application.
//
// Define a size for the CLA scratchpad area that will be used
// by the CLA compiler for local symbols and temps
// Also force references to the special symbols that mark the
// scratchpad area.
//
//
// If using --define CLA_SCRATCHPAD_SIZE=0x100, remove next line
//
CLA_SCRATCHPAD_SIZE = 0x100;
--undef_sym=__cla_scratchpad_end
--undef_sym=__cla_scratchpad_start
.....
MEMORY
{
.....
}
SECTIONS
{
//
// Must be allocated to memory the CLA has write access to
//
CLAscratch :
{ *.obj(CLAscratch)
. += CLA_SCRATCHPAD_SIZE;
*.obj(CLAscratch_end) } > CLARAM1, PAGE = 1
}
The scratchpad size can alternatively be defined and altered in the linker options of a project as
shown below
Function Nesting
Only 2 levels of call stack depth is supported. See Section 5.2.5 for details on the calling conven-
tions.
Recursion
Function Pointers
Other Operations
The following operations are currently not supported due to lack of instruction set support mak-
ing them expensive to implement. It is not clear that these operations are critical for typical CLA
algorithms.
The CLA compiler will place CLA code into section “Cla1Prog” as per the current convention used
for CLA assembly.
Global Data
Constants
Heap
There is no support for operations such as malloc(). Therefore there is no C system heap for CLA.
The compiler supports 2 level of function calls. Functions declared as interrupts may call leaf
functions only. Leaf function may not call other functions. Functions not declared as interrupt
will be considered leaf functions. N OTE : T HE CLA TASKS ARE PREFIXED WITH THE KEYWORD
’__interrupt’ TO SET THEM APART FROM LEAF FUNCTIONS . T HEY ARE NOT TO BE CONFUSED WITH
C 28 X INTERRUPT SERVICE ROUTINES
Register Save/Restore
All registers except for MR3 are saved on call. MR3 is saved on entry. NOTE: I F YOU ARE WRITING
AN ASM ROUTINE TO BE CALLED IN THE C CONTEXT IT IS YOUR RESPONSIBILITY TO SAVE / RESTORE
MR3 UPON ENTRY AND EXIT RESPECTIVELY
Local Variables
A static scratchpad area is used as a stack for locals and compiler temporary variables. N OTE :T HE
USER IS RESPONSIBLE FOR ENSURING THE SCRATCHPAD AREA IS ALLOCATED INTO THE MEMORY
MAP AND IS LARGE ENOUGH . T HIS IS DONE USING THE EITHER THE LINKER COMMAND FILE OR
THROUGH THE PROJECT ’ S LINKER OPTIONS ( SEE ABOVE ).
When interfacing with CLA assembly language modules use the calling conventions defined above
to interface with compiled CLA code.
5.3 Framework
The CLA examples are in the folder “examples\cla”. Each example within this folder share a similar
structure as shown in the figure below (Fig. 5.2)
For any given example there are 6 specific files associated with it as described in Table. 5.1.
<example>_main.c implements the main() routine. System and peripheral intialization is done
here along with setting up the CLA configuration registers.
<example>.cla The C implementation of all the CLA tasks. File level data global to the CLA
only(not shared with the C28x) should also be defined in this file.
<example>_run.c Contains routine test_run() called by main(). test_run() determines which CLA
tasks are triggered and if/how any data is passed to the task through the mes-
sage RAMs
<example>_shared.h External declarations for the global data defined in the C28x code and refer-
enced by the CLA task code.
<example>_shared_data.c Variables declared in <example>_shared.h are defined here and allocated to
memory (using #pragma DATA_SECTION). CLA VARIABLES MUST BE ALLO -
CATED TO A MEMORY SPACE THAT THE CLA HAS ACCESS TO, NAMELY THE
CLA<->CPU MESSAGE RAMS OR THE CLA DATA RAM S.
<example>_report.c Implements the routine test_report() which is called by main() after all CLA
tasks run to completion. The convention used for reporting test results is to
have the CLA task write results to a shared variable(s) and have the C28x
driver code call test_report() to compare the data to expected values and to
output the test run status to the CCS console. The convention used to check
the status of a test run is to expect the string “PASS” on success and “FAIL” on
failure. Other information can also be printed (eg. actual results vs expected
result) but the testing harness will expect, at the minimum, either PASS or FAIL
to be output.
NOTE: F OR EACH NEW WORKSPACE THE USER MUST CONFIGURE CCS IN THE MANNER DE -
SCRIBED BELOW
1. Go to Windows->Preferences->C/C++->File Types.
2. Select “New”
3. Type in *.cla in the top text box
4. In the drop down menu select C source file(see Fig. 5.3).
5. Select “ok”
The IDE will now recognize the .cla extension as code to be compiled.
I F YOU CREATE A NEW WORKSPACE YOU WILL NEED TO REPEAT THIS PROCESS . T HERE WILL BE A
FUTURE UPDATE TO CCS TO ADD THE ASSOCIATION AUTOMATICALLY.
1. Copy a Project:
Make a copy of the atan folder in the example directory and rename it to exp2
2. Rename Files:
Rename all files atan*.* to exp2*.*. (Notice the naming convention. All files have the test
folder name as a prefix, see Fig. 5.4 below)
Option Notes
Basic Options->Debugging Model->Full Symoblic debug (-g) If you would like to access
watch variables etc while debug-
ging(default setting).
Basic Options->Debugging Model->Suppress symbolic debug information View compiler generated as-
sembly code without all the de-
bug information.
Basic Options->Optimization Level = none - O2
D UE TO THE SMALL NUMBER
OF REGISTERS AVAILABLE LESS
AGGRESSIVE OPTIMIZATION MAY
YIELD BETTER RESULTS ( EG . -
O1 VS -O2).
Assembly Options -> Keep generated assembly files (-k) Useful if you want to compare
compiler generated code with
hand coded assembly.
5.5 Debugging
The user can follow these steps to start debugging their code on the CLA (The project exp2 is used
as an example here)
1. Add __mdebugstop()
Place an __mdebugstop() at the beginning of the CLA task you wish to debug. For exam-
ple, task 1 of exp2.cla.
2. Set build options:
You can setup individual build properties for the *.cla file seperately from the rest of the
application.
Right click the .cla file and select Properties->C/C++ Build.
3. Connect to the CLA:
Once you have built your project and launched the debug session CCS, by default, will
connect to only the C28 core.
To be able to debug CLA code you will need to connect to the CLA core. The action of
connecting to the CLA core enables all software breakpoints and single-stepping abilities.
I F YOU WISH TO STEP THROUGH C CODE BUILD THE PROJECT WITH - G (F ULL S YMBOLIC
D EBUG ) TO GENERATE THE SYMBOLS THAT WILL BE LOADED TO THE DEBUGGER.
(a) Click on the CLA debug session (highlighted in Fig. 5.6)
(b) Select Target->Connect to Target or hit Alt-C.
(c) Once the CLA core is connected proceed to load the project symbols by clicking on
Target->Load Symbols-><example>.out (e.g. exp2.out).
/********************************************************************
Shared Header File
********************************************************************/
typedef struct{
float a;
float *b;
float *c;
} foo;
/********************************************************************
main.c
********************************************************************/
#pragma(X,"CpuToCla1MsgRam") //Assign X to section CpuToCla1MsgRam
foo X;
/********************************************************************
test.cla
********************************************************************/
__interrupt void
Cla1Task1 ( void )
{
float f1,f2;
f1 = *(X.b);
//
// Pointer incorrectly dereferenced
// Tries to access location 0x1503 instead of 0x1504
//
f2 = *(X.c);
}
Assume that the C28 compiler will allocate space for X at the top of the section CpuToCla1MsgRam
as follows:
Element Address
X.a 0x1500
X.b 0x1502
X.c 0x1504
Element Address
X.a 0x1500
X.b 0x1502
X.c 0x1503
The CLA compiler treats pointers b and c as 16-bits wide and therefore incorrectly dereferences
pointer c.
The solution to this is to declare a new pointer as follows:
/********************************************************************
Shared Header File
********************************************************************/
typedef union{
float *ptr; //Aligned to lower 16-bits
Uint32 pad; //32-bits
} CLA_FPTR;
typedef struct{
float a;
CLA_FPTR b;
CLA_FPTR c;
} foo;
/********************************************************************
main.c
********************************************************************/
#pragma(X,"CpuToCla1MsgRam") //Assign X to section CpuToCla1MsgRam
foo X;
/********************************************************************
test.cla
********************************************************************/
__interrupt void
Cla1Task1 ( void )
{
float f1,f2;
f1 = *(X.b.ptr);
f2 = *(X.c.ptr); //Correct Access
}
The new pointer CLA_FPTR is a union of a 32-bit integer and a pointer to a float. The CLA compiler
recognizes the size of the larger of the two elements(the 32 bit integer) and therefore aligns the
pointer to the lower 16-bits. Now both the pointers b and c will occupy 32-bit memory spaces and
any instruction that tries to dereference pointer c will access the correct address 0x1504.
5.7.2 Benchmarking
The CLA does not support the clock function and therefore it is not possible to get a direct cycle
count of a particular task. The user can configure the time base module on an ePWM to keep track
of the execution time of a task
Setup the time base of ePWM1(or any ePWM) to run at SYSCLKOUT in the up-count mode as
shown below:
void
InitEPwm(void)
{
//
// Setup TBCLK
//
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm1Regs.TBPRD = 0xFFFF; // Set timer period
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
}
Proceed to define two macros READ_CLOCK and RESTART_CLOCK, the former to freeze the
ePWM timer and copy the elapsed time to a variable, and the latter to restart the ePWM timer.
#pragma DATA_SECTION(ulCycleCount,"Cla1ToCpuMsgRAM");
unsigned long ulCycleCount;
Place the macro RESTART_CLOCK at the beginning of a task to restart the ePWM timer and place
READ_CLOCK at the end of the task to read the value of the timer. The elapsed time will be give
you the cycle count plus a minimal overhead from the two macros
__interrupt void
Cla1Task1 ( void )
{
//
// Local Variables
//
float a;
__mdebugstop();
RESTART_CLOCK;
a = 10;
...
...
...
READ_CLOCK(ulCycleCount);
}
.sect "Cla1Prog"
_Cla1Prog_ASM_start:
.align 2
_Cla1Task1:
...
...
...
MSTOP
_Cla1Task1End:
The C tasks are defined in the usual way. The only difference between the two is the manner in
which the MVECT’s are initialized
For assembly tasks the MVECT is as follows:
where Cla1Prog_Start is a linker defined variable which must be declared in a .c file with the
storage classifier extern
Notes
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Val - Input
ExpRes - Result of 10V al
Memory Allocation
A
6.9 e B using a lookup table
In this example, Task 1 of the CLA will divide two input numbers using multiple approximations in
the Newton Raphson method and then calculate the exponent of the result using a lookup table
Watch Variables
Memory Allocation
Memory Allocation
fBiquadOutput
Memory Allocation
The coefficients in this example were generated in MATLAB using “fdatool” as shown in fig.6.1.
The Frequency specification shown in the image is for demonstration purposes only and was not
used to generate the coefficients in the example code.
Once the parameters are set and the filter designed, the user can view the coefficients from the
analysis menu shown below
MATLAB implements IIR filters in cascading “Second Order Section” of the form
1
y(n) = × (b(0)x(n) + b(1)x(n − 1) + b(2)x(n − 2) + (−a(1))y(n − 1) + (−a(2))y(n − 2)) (6.2)
a(0)
The “a” coefficients, with the exception of a(0), must be negated. In the example, the original
coefficients were
The “a” coefficients(except a(0)) are negated to fit the second-order structure implemented in code.
#pragma DATA_SECTION(S1_B,"Cla1DataRam1")
float S1_B[]={0.02008, 0.04017, 0.02008};
#pragma DATA_SECTION(S1_A,"Cla1DataRam1")
float S1_A[]={1.0, 1.56102, -0.64135};
Note that a(0) is hardcoded to a constant(1) and, as such, is not required in the coefficient array. It
is present only to facilitate readability of the code.
Memory Allocation
Memory Allocation
Memory Allocation
6.15 Primes
Task 1 calculates the set of prime numbers upto a length defined by the user
Watch Variables
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Memory Allocation
Description:
Downloads images to a Texas Instruments microcontroller running the USB Device Firmware
Upgrade boot loader. Additionally, this utility may be used to read back the existing application
image or a subsection of flash and store it either as raw binary data or as a DFU-downloadable
image file.
The source code for this utility is contained in tools/dfuprog. A Microsoft Visual Studio
project file is provided to allow the application to be built.
Arguments:
-e specifies the address of the binary.
-u specifies that an image is to be uploaded from the board into the target file. If absent, the
file will be downloaded to the board.
-c specifies that a section of flash memory is to be cleared. The address and size of the block
may be specified using the -a and -l parameters. If these are absent, the entire writable
area of flash is erased.
-f FILE specifies the name of the file to download or, if -u is given, to upload.
-b specifies that an uploaded file is to be stored as raw binary data without the DFU file wrap-
per. This option is only valid if used alongside -u.
-d specifies that the VID and PID in the DFU file wrapper should be ignored for a download
operation.
-s specifies that image verification should be skipped following a download operation.
-a ADDR specifies the address at which the binary file will be downloaded or from which an
uploaded file will be read. If a download operation is taking place and the source file
provided is DFU-wrapped, this parameter will be ignored.
-l SIZE specifies the number of bytes to be uploaded when used in conjunction with -i or the
number of bytes of flash to erase if used in conjunction with -c.
-i NUM specifies the zero-based index of the USB DFU device to access if more than one is
currently attached to the system. If absent, the first device found is used.
-x specifies that destination file for an upload operation should be overwritten without prompt-
ing if it already exists.
-w specifies that the utility should wait for the user to press a key before it exits.
-v displays verbose output during the requested operation.
-h displays this help information.
-? displays this help information.
Example:
The following example writes binary file program.bin to the device flash memory at address
0x1800:
The following example writes DFU-wrapped file program.dfu to the flash memory of the second
connected USB DFU device at the address found in the DFU file prefix:
dfuprog -i 1 -f program.dfu
The following example uploads (reads) the current application image into a DFU-formatted file
appimage.dfu:
dfuprog -u -f appimage.dfu
C2000 board. This application then inverts the case of the alphabetic characters in the string
and returns the data back to the USB host where it is displayed.
The source code for this application is contained in tools/usb_bulk_example. The binary
can be found in the tools/usb_bulk_example/debug directory. A Microsoft Visual Studio
project file is provided to allow the application to be built.
8.1 Introduction
The command line processor allows a simple command line interface to be made available in an
application, for example via a UART. It takes a buffer containing a string (which must be obtained
by the application) and breaks it up into a command and arguments (in traditional C “argc, argv”
format). The command is then found in a command table and the corresponding function in the
table is called to process the command.
This module is contained in utils/cmdline.c, with utils/cmdline.h containing the API def-
initions for use by applications.
//
// Code for the "foo" command.
//
int
ProcessFoo(int argc, char *argv[])
{
//
// Do something, using argc and argv if the command takes arguments.
//
}
//
// Code for the "bar" command.
//
int
ProcessBar(int argc, char *argv[])
{
//
// Do something, using argc and argv if the command takes arguments.
//
}
//
//
// The table of commands supported by this application.
//
tCmdLineEntry g_sCmdTable[] =
{
{ "foo", ProcessFoo, "The first command." },
{ "bar", ProcessBar, "The second command." },
{ "help", ProcessHelp, "Application help." }
};
//
// Read a process a command.
//
int
Test(void)
{
unsigned char pucCmd[256];
//
// Retrieve a command from the user into pucCmd.
//
...
//
// Process the command line.
//
return(CmdLineProcess(pucCmd));
}
9.1 Introduction
The UART standard IO module provides a simple interface to a UART that is similar to the standard
IO package available in the C library. Only a very small subset of the normal functions are provided;
UARTprintf() is an equivalent to the C library printf() function and UARTgets() is an equivalent to
the C library fgets() function.
This module is contained in utils/uartstdio.c, with utils/uartstdio.h containing the API
definitions for use by applications.
//
// Configure the appropriate pins as UART pins; in this case, PA0/PA1 are
// used for UART0.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Initialize the UART standard IO module.
//
UARTStdioInit(0);
//
// Print a string.
//
UARTprintf("Hello world!\n");
CPU Interrupts INT1 - INT14, DLOGINT and RTOSINT are maskable interrupts. These interrupts
can be enabled or disabled by the CPU Interrupt enable register (IER).
Group Priority (PIE Level):
If the Peripheral Interrupt Expansion (PIE) block is enabled, then CPU interrupts INT1 to INT12 are
connected to the PIE. This peripheral expands each of these 12 CPU interrupt into 8 interrupts.
Thus the total possible number of available interrupts in the PIE is 96. Note, not all of the 96 are
used on a 2806x device.
Each of the PIE groups has its own interrupt enable register (PIEIERx) to control which of the 8
interrupts (INTx.1 - INTx.8) are enabled and permitted to issue an interrupt.
CPU PIE
Interrupt Group PIE Interrupts
Highest————–Hardware Priority Within the Group—————-Lowest
INT1 1 INT1.1 INT1.2 INT1.3 INT1.4 INT1.5 INT1.6 INT1.7 INT1.8
INT2 2 INT2.1 INT2.2 INT2.3 INT2.4 INT2.5 INT2.6 INT2.7 INT2.8
INT3 3 INT3.1 INT3.2 INT3.3 INT3.4 INT3.5 INT3.6 INT3.7 INT3.8
... etc ...
... etc ...
INT12 12 INT12.1 INT12.2 INT12.3 INT12.4 INT12.5 INT12.6 INT12.7 INT4.8
On the 2806x, such interrupts are allocated to the first few interrupts within PIE Group 1 and
PIE Group 2. This position gives them the highest priority within the PIE group. In addition,
Group 1 is multiplexed into the CPU interrupt INT1. CPU INT1 has the highest hardware
priority. PIE Group 2 is multiplexed into the CPU INT2 which is the 2nd highest hardware
priority.
On the 2806x, such interrupts are allocated to the group 1 in the PIE table. Group 1 is
multiplexed into the CPU INT1. CPU INT1 has the highest hardware priority
3. Periodic
These interrupts occur at a known period and must be serviced before the next interrupt.
Some of the PWM interrupts are an example of this. Many of the registers are shadowed, so
the user has the full period to update the register values.
In the 2806x PIE module, such interrupts are mapped to group 2 - group 5. These groups
are multiplexed into CPU INT3 to INT5 (the ePWM and eCAP), which are the next lowest
hardware priority.
4. Periodic, Buffered
These interrupts occur at periodic events, but are buffered and hence the processor need
only service such interrupts when the buffers are ready to filled/emptied. All of the serial ports
(SCI/ SPI/ I2C/ CAN/ McBSP) either have FIFOs or multiple mailboxes such that the CPU has
plenty of time to respond to the events without fear of losing data.
In the 2806x, such interrupts are mapped to INT6, INT8, and INT9, which are the next lowest
hardware priority.
Global Priority
This priority can be managed by manipulating the CPU IER register. This register controls the
16 maskable CPU interrupts (INT1 - INT16).
Group Priority
This can be managed by manipulating the PIE block interrupt enable registers (PIEIERx).
There is one PIEIERx per group and each control the 8-interrupts multiplexed within that group.
The DSP28 software prioritization of interrupt example demonstrates how to configure the Global
priority (via IER) and group priority (via PIEIERx) within an ISR in order to change the interrupt
service priority based on user assigned levels. The steps required to do this are:
3. Enable interrupts
The DSP28 software prioritized interrupts example provides a method using mask values that are
configured during compile time to allow you to manage this easily.
To setup software prioritization for the DSP28 example, the user must first assign the desired global
priority levels and group priority levels.
This is done in the F2806x_SWPrioritizedIsrLevels.h file as follows:
These values are used to assign a priority level to each of the 8 interrupts within a PIE group.
A value of 1 is the highest priority while a value of 8 is the lowest. More then one interrupt can
be assigned the same priority level. In this case the default hardware priority would determine
which would be serviced first. A priority of 0 is used to indicate that the interrupt is not used.
Once the user has defined the global and group priority levels, the compiler will generate mask
values that can be used to change the IER and PIEIERx registers within each ISR. In this manner
the interrupt software prioritization will be changed. The masks that are generated at compile time
are:
The user assigned INT1PL - INT16PL values are used at compile time to calculate an IER
mask for each CPU interrupt. This mask value will be used within an ISR to allow CPU inter-
rupts with a higher priority to interrupt the current ISR and thus be serviced at a higher priority
level.
PIEIERxy mask values
MGxy (where x = PIE group number 1 - 12 and y = interrupt number 1 - 8)
The assigned group priority levels (GxyPL) are used at compile time to calculate PIEIERx
masks for each PIE group. This mask value will be used within an ISR to allow interrupts
within the same group that have a higher assigned priority to interrupt the current ISR and
thus be serviced at a higher priority level.
//
// EPWM1_TZINT_ISR - EPWM1 Trip Zone is connected to PIEIER2_1
// (use MINT2 and MG21 masks)
//
#if (G21PL != 0)
interrupt void
EPWM1_TZINT_ISR(void)
{
//
// Set interrupt priority
//
volatile Uint16 TempPIEIER = PieCtrlRegs.PIEIER2.all;
IER |= M_INT2;
IER &= MINT2; // Set "global" priority
PieCtrlRegs.PIEIER2.all &= MG21; // Set "group" priority
PieCtrlRegs.PIEACK.all = 0xFFFF; // Enable PIE interrupts
EINT;
//
// Insert ISR Code here
//
//
// for now just insert a delay
//
for(i = 1; i <= 10; i++)
{
//
// Restore registers saved
//
DINT;
PieCtrlRegs.PIEIER2.all = TempPIEIER;
//
// Add ISR to Trace
//
ISRTrace[ISRTraceIndex] = 0x0021;
ISRTraceIndex++;
}
#endif
CMP1INT_ISR:
ASP
ADDB SP,#1
CLRC OVM,PAGE0
MOVW DP,#0x0033
MOV AL,@36
MOV *-SP[1],AL
OR IER,#0x0002
AND IER,#0x0002
AND @36,#0x000E
MOV @33,#0xFFFF
CLRC INTM
SETC INTM
MOV AL,*-SP[1]
MOV @36,AL
SUBB SP,#1
NASP
IRET
B.1 Introduction
To compensate the internal oscillator, the Texas Instruments factory takes measurements of the
internal oscillator and temperature sensor. It then calculates a reference point for the temperature
sensor and oscillator trim and calculates an oscillator trim slope. The trim slope can be used
to adjust the oscillator fine trim as the temperature sensor reading moves away from that of the
reference point.
The reference point for the internal oscillator consists of two pieces of data. The first is the temper-
ature sensor reading at that point. The second is the oscillator trim values to get 10.0MHz at that
temperature. This trim itself is composed of two parts: the fine trim and the coarse trim. Only the
fine trim will be adjusted by the compensation procedure. The coarse trim remains the same no
matter what temperature the device is at.
The oscillator compensation slope contains the information needed to adjust the oscillator fine trim
from the reference fine trim as the temperature moves away from the reference temperature. This
slope has the units of oscillator fine trim steps / ADC codes (temperature sensor output).
If X is considered to be the temperature sensor reading and Y is considered to be the oscillator fine
trim, then the basic oscillator compensation equation is
Y1 = m ∗ (X1 − X0 ) + Y0 (B.1)
where,
Y1 is the oscillator fine trim at the current temperature
Y0 is the oscillator fine trim at the reference temperature
X1 is the temperature sensor reading at the current temperature
X0 is the temperature sensor reading at the reference temperature
change in oscillator f ine trim
m is the oscillator compensation slope, which is change in temperature sensor reading
C.1 Introduction
This document describes the updates to the Scale Factor Optimization (SFO) V6 library files
packaged with the C/C++ Header Files and Peripheral Examples software package.
SFO_TI_Build_V6x.lib (where “x” represents the alphabetical revision letter of the library).
SFO_V6.h
Errors Fixed:
The SFO_V6() function now properly
updates the HRMSTEP register with
MEP_ScaleFactor after calibration is
complete.
Example:
if (SFO_V6(n)==SFO_COMPLETE) {
EALLOW;
EPwm1Regs.HRMSTEP = MEP_ScaleFactor;
EDIS;
}
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2021, Texas Instruments Incorporated