DSP281x Header Files Quick Start Readme
DSP281x Header Files Quick Start Readme
Version 1.20
July 27, 2009
1 Device Support:............................................................................................................................ 2
2 Introduction: ................................................................................................................................. 2
2.1 Revision History...................................................................................................................... 3
2.2 Where Files are Located (Directory Structure) ........................................................................ 3
3 Understanding The Peripheral Bit-Field Structure Approach ................................................... 5
4 Peripheral Example Projects ....................................................................................................... 5
4.1 Getting Started ....................................................................................................................... 5
4.1.1 Getting Started in Code Composer Studio v3.x ........................................................... 5
4.1.2 Getting Started in Code Composer Studio v4.............................................................. 8
4.2 Example Program Structure.................................................................................................. 11
4.2.1 Include Files.............................................................................................................. 11
4.2.2 Source Code ............................................................................................................. 12
4.2.3 Linker Command Files .............................................................................................. 12
4.3 Example Program Flow......................................................................................................... 14
4.4 Included Examples: .............................................................................................................. 15
4.5 Executing the Examples From Flash..................................................................................... 16
5 Steps for Incorporating the Header Files and Sample Code ................................................... 19
5.1 Before you begin................................................................................................................... 19
5.2 Including the DSP281x Peripheral Header Files ................................................................... 19
5.3 Including Common Example Code........................................................................................ 24
6 Troubleshooting Tips & Frequently Asked Questions............................................................. 27
6.1 Effects of read-modify-write instructions. .............................................................................. 29
6.1.1 Registers with multiple flag bits in which writing a 1 clears that flag........................... 29
6.1.2 Registers with Volatile Bits. ....................................................................................... 30
7 Migration Tips from V.58 to V1.00 and newer........................................................................... 30
8 Packet Contents: ........................................................................................................................ 38
8.1 Header File Support – DSP281x_headers ............................................................................ 38
8.1.1 DSP281x Header Files – Main Files.......................................................................... 38
8.1.2 DSP281x Header Files – Peripheral Bit-Field and Register Structure Definition Files 39
8.1.3 Code Composer .gel Files......................................................................................... 39
8.1.4 Variable Names and Data Sections........................................................................... 40
8.2 Common Example Code – DSP281x_common .................................................................... 40
8.2.1 Peripheral Interrupt Expansion (PIE) Block Support .................................................. 40
8.2.2 Peripheral Specific Files............................................................................................ 41
8.2.3 Utility Function Source Files...................................................................................... 42
8.2.4 Example Linker .cmd files ......................................................................................... 42
9 Detailed Revision History: ......................................................................................................... 43
10 Errata: ......................................................................................................................................... 45
1
V1.20 Quick Start Readme
1 Device Support:
This software package supports 281x devices. This includes the following: TMS320F2812,
TMS320F2811, TMS320F2810, TMS320C2812, TMS320C2811, TMS320C2810,
TMS320R2812, and TMS320R2811.
Throughout this document, TMS320F2812, TMS320F2811, TMS320F2810, TMS320C2812,
TMS320C2811, TMS320C2810, TMS320R2812, and TMS320R2811 are abbreviated as F2812,
F2811, F2810, C2812, C2811, C2810, R2812, and R2811, respectively.
2 Introduction:
The DSP281x peripheral header files and example projects included in (SPRC097) facilitate
writing in C/C++ Code for the Texas Instruments ‘281x DSPs. 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.
• Learning Tool:
This download includes several example Code Composer Studio™† projects for a ‘281x
development platform. One such platform is the eZdsp™†† F2812 USB from Spectrum
Digital Inc. (www.spectrumdigital.com).
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
allocation in the linker command file.
• 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.
To get started this document provides the following information:
• Overview of the bit-field structure approach used in the DSP281x C/C++ peripheral header
files.
• Steps for integrating the peripheral header files into a new or existing project.
†
Code Composer Studio is a trademark of Texas Instruments (www.ti.com).
††
eZdsp is a trademark of Spectrum Digital Inc (www.spectrumdigital.com).
Trademarks are the property of their respective owners.
2
SPRC097 Version 1.20 Quick Start Readme
• Troubleshooting tips and frequently asked questions.
• Migration tips for users moving from the previous release V.58 to V1.00 and newer.
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 281x
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.
3
V1.20 Quick Start Readme
Under the DSP281x_headers and DSP281x_common directories the source files are further
broken down into sub-directories each indicating the type of file. Table 2 lists the sub-directories
and describes the types of files found within each:
DSP281x_common\cmd Example memory command files that allocate memory on the ‘281x devices.
DSP281x_common\include Common .h files that are used by the DSP281x peripheral examples.
DSP281x_common\source Common .c files that are used by the DSP281x peripheral examples.
4
SPRC097 Version 1.20 Quick Start Readme
This application note explores the hardware abstraction layer implementation to make C/C++
coding easier on 28x DSPs. This method is compared to traditional #define macros and topics of
code efficiency and special case registers are also addressed.
5
V1.20 Quick Start Readme
/********************************************************************
* DSP281x_headers\include\DSP281x_Device.h
********************************************************************/
#define TARGET 1
//---------------------------------------------------------------------------
// User To Select Target Device:
4. Edit DSP281x_Examples.h
Edit DSP281x_Examples.h and specify the clock rate.
In DSP281x_Examples.h specify the SYSCLKOUT period. This value is used to scale a
delay loop used by the examples. The default value is for 150Mhz SYSCLKOUT.
/********************************************************************
* DSP281x_common\include\DSP281x_Examples.h
********************************************************************/
……
#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 7.143L // for a 140MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 8.333L // for a 120MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 10.000L // for a 100MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 13.330L // for a 75MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 41.667L // for a 24MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 50.000L // for a 20MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 66.667L // for a 15MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 100.000L // for a 10MHz CPU clock speed (SYSCLKOUT)//-----------
-----------------------------------------------------------------
5. Review the comments at the top of the main source file: Example_281xCpuTimer.c.
A brief description of the example and any assumptions that are made and any external
hardware requirements are listed in the comments at the top of the main source file.
6. Perform any hardware setup required by the example.
Perform any hardware setup indicated by the comments in the main source. The DSP281x
CPU-Timer example only requires that the hardware be setup for “Boot to H0” mode. Other
examples may require additional hardware configuration such as connecting pins together or
pulling a pin high or low.
Table 3 shows a listing of the boot mode pin settings for reference. For users with the F2812
eZdsp from Spectrum Digital, refer to the eZdsp’s user’s guide for the jumpers corresponding
to the boot mode selection. For more information on the ‘281x boot modes refer to the
TMS320F28x Boot ROM Reference Guide (SPRU095).
6
SPRC097 Version 1.20 Quick Start Readme
7
V1.20 Quick Start Readme
4.1.2 Getting Started in Code Composer Studio v4
To get started, follow these steps to load the 32-bit CPU-Timer example. Other examples are
set-up in a similar manner.
1. Have a hardware platform connected to a host with Code Composer Studio installed.
NOTE: As supplied, the ‘280x example projects are built for the ‘2808 device. If you are
using another 280x 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 “imported”/opened in Code Composer
Studio v4.
To open the ‘280x CPU-Timer example project directory, follow the following steps:
e. In Code Composer Studio v 4.x: Project->Import Existing CCS/CCE Eclipse Project.
f. Next to “Select Root Directory”, browse to the CPU Timer example directory:
DSP280x_examples_ccsv4\cpu_timer. Select the Finish button.
This will import/open the project in the CCStudio v4 C/C++ Perspective project.
3. Edit DSP28_Device.h
Edit the DSP281x_Device.h file in the DSP281x_headers\include directory and make
sure the appropriate device is selected. By default the 2812 is selected.
/********************************************************************
* DSP281x_headers\include\DSP281x_Device.h
********************************************************************/
#define TARGET 1
//---------------------------------------------------------------------------
// User To Select Target Device:
4. Edit DSP281x_Examples.h
Edit DSP281x_Examples.h and specify the clock rate.
In DSP281x_Examples.h specify the SYSCLKOUT period. This value is used to scale a
delay loop used by the examples. The default value is for 150Mhz SYSCLKOUT.
8
SPRC097 Version 1.20 Quick Start Readme
/********************************************************************
* DSP281x_common\include\DSP281x_Examples.h
********************************************************************/
……
#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 7.143L // for a 140MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 8.333L // for a 120MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 10.000L // for a 100MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 13.330L // for a 75MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 41.667L // for a 24MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 50.000L // for a 20MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 66.667L // for a 15MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 100.000L // for a 10MHz CPU clock speed (SYSCLKOUT)//-----------
-----------------------------------------------------------------
5. Review the comments at the top of the main source file: Example_281xCpuTimer.c.
A brief description of the example and any assumptions that are made and any external
hardware requirements are listed in the comments at the top of the main source file.
6. Perform any hardware setup required by the example.
Perform any hardware setup indicated by the comments in the main source. The DSP281x
CPU-Timer example only requires that the hardware be setup for “Boot to H0” mode. Other
examples may require additional hardware configuration such as connecting pins together or
pulling a pin high or low.
Table 3 shows a listing of the boot mode pin settings for reference. For users with the F2812
eZdsp from Spectrum Digital, refer to the eZdsp’s user’s guide for the jumpers corresponding
to the boot mode selection. For more information on the ‘281x boot modes refer to the
TMS320F28x Boot ROM Reference Guide (SPRU095).
9
V1.20 Quick Start Readme
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 4.2 and 4.3 describe the structure and flow of the examples in more detail.
10. When done, delete the project from the Code Composer Studio v4 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 DSP2802x_headers directory and shared source in
the DSP2802x_common directory. Only example files specific to a particular example are
located within in 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.
10
SPRC097 Version 1.20 Quick Start Readme
DSP281x_GlobalVariableDefs.c
This source file is required to use the DSP281x peripheral header files.
DSP281x_Headers_nonBIOS.cmd
Linker file required by the peripheral specific header files.
/********************************************************************
* DSP281x_examples\cpu_timer\Example_281xCpuTimer.c
********************************************************************/
• DSP281x_Device.h
This header file is required to use the DSP281x peripheral header files. This file includes all
of the required peripheral specific header files and includes device specific macros and
typedef statements. This file is found in the DSP281x_headers\include directory.
• DSP281x_Examples.h
This header file defines parameters that are used by the example code. This file is not
required to use just the DSP281x peripheral header files but is required by some of the
common source files. This file is found in the DSP281x_common\include directory.
11
V1.20 Quick Start Readme
• DSP281x_GlobalVariableDefs.c
Any project that uses the DSP281x 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 DSP281x_headers\source directory.
12
SPRC097 Version 1.20 Quick Start Readme
Table 5. Included Memory Linker Command Files
13
V1.20 Quick Start Readme
Reset
Boot ROM or
Boot from XINTF Zone 7
Initalize Peripherals
Remap PIE vectors used by the example to ISR
functions found within the example program.
14
SPRC097 Version 1.20 Quick Start Readme
15
V1.20 Quick Start Readme
4.5 Executing the Examples From Flash
Most of the DSP281x examples execute from SARAM in “boot to H0” mode. One example,
DSP281x_examples\Flash, executes from flash memory in “boot to flash” mode. This example
is the Event Manager timer example with the following changes made to execute out of flash:
1. Change the linker command file to link the code to flash.
Remove F2812_EzDSP_RAM_lnk.cmd from the project and add F2812.cmd or F2810.cmd.
Both F2810.cmd and F2812.cmd are located in the DSP281x_common\cmd\ directory.
2. Add the DSP281x_common\source\DSP281x_CSMPasswords.asm to the project.
This file contains the passwords that will be programmed into the Code Security Module
(CSM) password locations. Leaving the passwords set to 0xFFFF during development is
recommended as the device can easily be unlocked. For more information on the CSM refer
to the TMS320F28x System Control and Interrupts Reference Guide (SPRU078).
3. Modify the code to copy functions that must be executed in SARAM from their load
address in flash to their run address in SARAM.
In particular, the flash wait state initialization routine must be executed out of SARAM. In
the DSP281x examples, functions that are to be executed from SARAM have been
assigned to the ramfuncs section by compiler CODE_SECTION #pragma statements as
shown in the example below.
/********************************************************************
* DSP281x_common\source\DSP281x_SysCtrl.c
********************************************************************/
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:
/********************************************************************
* DSP281x_common\include\F2812.cmd
********************************************************************/
SECTIONS
{
ramfuncs : LOAD = FLASHD,
RUN = RAML0,
LOAD_START(_RamfuncsLoadStart),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
PAGE = 0
}
16
SPRC097 Version 1.20 Quick Start Readme
The linker will assign symbols as specified above to specific addresses as follows:
Address Symbol
Load start RamfuncsLoadStart
Load end RamfuncsLoadEnd
Run start RamfuncsRunStart
These symbols can then be used to copy the functions from the Flash to SARAM using the
included example MemCopy routine or the C library standard memcopy() function.
To perform this copy from flash to SARAM using the included example MemCopy function:
a. Add the file DSP281x_common\source\DSP281x_MemCopy.c to the project.
b. Add the following function prototype to the example source code. This is done for you in
the DSP281x_Examples.h file.
/********************************************************************
* DSP281x_common\include\DSP281x_Examples.h
********************************************************************/
c. Add the following variable declaration to your source code to tell the compiler that these
variables exist. The linker command file will assign the address of each of these
variables as specified in the linker command file as shown in step 3. For the DSP281x
example code this has is already done in DSP281x_Examples.h.
/********************************************************************
* DSP281x_common\include\DSP281x_Examples.h
********************************************************************/
d. Modify the code to call the example MemCopy function for each section that needs to be
copied from flash to SARAM.
/********************************************************************
* DSP281x_examples\Flash source file
********************************************************************/
17
V1.20 Quick Start Readme
/********************************************************************
* DSP281x peripheral example .c file
********************************************************************/
InitFlash();
For users with the F2812 eZdsp from Spectrum Digital, refer to the eZdsp’s user’s guide for
the jumpers corresponding to the boot mode selection.
For more information on the ‘281x boot modes refer to the TMS320F28x Boot ROM
Reference Guide (SPRU095).
6. Program the device with the built code.
In Code Composer Studio v4, when code is loaded into the device during debug, it
automatically programs to flash memory
This can also be done using SDFlash available from Spectrum Digital’s website
(www.spectrumdigital.com). In addition the C2000 on-chip Flash programmer plug-in for
Code Composer Studio v3.x.
These tools will be updated to support new devices as they become available. Please
check for updates.
7. In Code Composer Studio v3, to debug, load the project in CCS, select File->Load
Symbols->Load Symbols Only.
It is useful to load only symbol information when working in a debugging environment where
the debugger cannot or need not load the object code, such as when the code is in ROM or
flash. This operation loads the symbol information from the specified file.
18
SPRC097 Version 1.20 Quick Start Readme
/********************************************************************
* User’s source file
********************************************************************/
#include “DSP281x_Device.h”
2. Edit DSP281x_Device.h and select the target you are building for:
In the below example, the file is configured to build for the F2812 device.
/********************************************************************
* DSP281x_headers\include\DSP281x_Device.h
********************************************************************/
#define TARGET 1
#define DSP28_F2812 TARGET
#define DSP28_F2811 0
#define DSP28_F2810 0
19
V1.20 Quick Start Readme
/********************************************************************
* User’s linker .cmd file
********************************************************************/
†
DSP/BIOS is a trademark of Texas Instruments
20
SPRC097 Version 1.20 Quick Start Readme
2) Add the directory path to the DSP281x peripheral linker .cmd file to your
project.
Code Composer Studio 3.x
a. Open the menu: Project->Build Options
b. Select the Linker tab and then Select Basic.
c. In the Library Search Path, add the directory path to the location of the
DSP281x_headers\cmd directory on your system.
Code Composer Studio 4.x
Method #1
a. Right-click on the project in the project window of the C/C++ Projects perspective.
a. Right-click on the project in the project window of the C/C++ Projects perspective.
b. Select New->File.
e. Select the Variables… button. From the list, pick the linked variable (macro defined
in your macros.ini file) associated with your installation directory. (For the 280x
header files, this is INSTALLROOT_280X_V<version #>). For more information on
linked variables and the macros.ini file, see:
http://tiexpressdsp.com/index.php/Portable_Projects_in_CCSv4_for_C2000#Method
_.232_for_Linking_Files_to_Project:
f. Click on the Extend…” button. Navigate to the desired .cmd file and select OK.
21
V1.20 Quick Start Readme
5. Add the directory path to the DSP281x header files to your project.
Code Composer Studio 3.x
To specify the directory where the
header files are located:
a. Open the menu:
Project->Build Options
b. Select the Compiler tab
c. Select pre-processor.
d. In the Include Search Path,
add the directory path to the
location of
DSP281x_headers\include on
your system.
Code Composer Studio 4.x
To specify the directory where the header files are located:
a. Open the menu: Project->Properties.
b. In the menu on the left, select “C/C++ Build”.
c. In the “Tool Settings” tab, Select “C2000 Compiler -> Include Options:”
d. In the “Add dir to #include search path (--include_path, -I” window, select the “Add” icon
in the top right corner.
e. Select the “File system…” button and navigate to the directory path of
DSP280x_headers\include on your system.
22
SPRC097 Version 1.20 Quick Start Readme
23
V1.20 Quick Start Readme
/********************************************************************
* User’s source file
********************************************************************/
#include “DSP281x_Examples.h”
2. Add the directory path to the example include files to your project.
Code Composer Studio 3.x
To specify the directory where
the header files are located:
a. Open the menu:
Project->Build Options
b. Select the Compiler tab
c. Select pre-processor.
d. In the Include Search Path,
add the directory path to
the location of
DSP281x_common/include
on your system.
Use a semicolon between
directories.
For example the directory path for the included projects is:
..\..\DSP281x_headers\include;..\..\DSP281x_common\include
Code Composer Studio 4.x
To specify the directory where the header files are located:
a. Open the menu: Project->Properties.
b. In the menu on the left, select “C/C++ Build”.
c. In the “Tool Settings” tab, Select “C2000 Compiler -> Include Options:”
d. In the “Add dir to #include search path (--include_path, -I” window, select the “Add” icon
in the top right corner.
e. Select the “File system…” button and navigate to the directory path of
DSP280x_headers\include on your system.
24
SPRC097 Version 1.20 Quick Start Readme
/********************************************************************
* DSP281x_common\include\DSP281x_Examples.h
********************************************************************/
25
V1.20 Quick Start Readme
26
SPRC097 Version 1.20 Quick Start Readme
• I re-built one of the projects to run from Flash and now it doesn’t work. What could be
wrong?
Make sure that all initialized sections, such as .econst, are allocated to page 0 in the linker
command file (.cmd). SDFlash will only program sections in the .out file that are allocated
to page 0.
27
V1.20 Quick Start Readme
• 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 un-modified 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 many of the examples, the compiler outputs the following: remark:
controlling expression is constant. What does this mean?
Many 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:
statement is unreachable. What does this mean?
Many 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. For example in the
McBSP loopback program, depending on which serial word size the example is compiled
for, some code may never be used.
• 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->Configurations) the compiler 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->Build
Options) and enter the following information:
– Compiler Tab, Preprocessor: Include search path
– Linker Tab, Basic: Library search path
– Linker Tab, Basic: Include libraries (ie rts2800_ml.lib)
Refer to section 4.5 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 code. This is why the
breakpoint is never hit. To avoid this, set the breakpoint after the SARAM functions have
been copied to SARAM.
28
SPRC097 Version 1.20 Quick Start Readme
• The eCAN control registers require 32-bit write accesses.
The compiler will instead make a 16-bit write accesses if it can in order to improve codesize
and/or performance. This can result in unpredictable results.
One method to avoid this is to create a duplicate copy of the eCAN control registers in RAM.
Use this copy as a shadow register. First copy the contents of the eCAN register you want
to modify into the shadow register. Make the changes to the shadow register and then write
the data back as a 32-bit value. This method is shown in the DSP281x_examples\
ecan_back2back example project.
6.1.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
********************************************************************/
29
V1.20 Quick Start Readme
30
SPRC097 Version 1.20 Quick Start Readme
– Memory linker .cmd files are located in DSP281x_common\cmd
– If you were using the file: EzDSP_RAM_lnk.cmd, then remove this file from the project
and replace it with F2812_EzDSP_RAM_lnk.cmd located in DSP281x_common\cmd
5. Follow all of the steps in Section 5 to incorporate the header files and example
source into your existing project. Some of these steps may already be complete.
Some of the major differences between V.58 and V1.00 and newer are highlighted below:
– Section 5.2 step 6: Include the header linker command file. The linker files have now
been split into memory specific and peripheral header file specific files.
– Section 5.2 step 7: Update the include search path for the new location of the header
files.
– Section 5.3 step 1 & 2: If your project uses any of the sample code, include
DSP281x_Examples.h in your source code. This file contains the example specific
information that used to be part of DSP281x_Device.h.
6. Build the project.
The compiler will highlight areas that have changed. Most of the changes will be bit-name
or register name corrections to align with the peripheral user guides. Some example errors
and their solutions are outlined below.
– Register name has changed to align with the user’s guide:
Example: struct "EVA_REGS" has no field "CAPCON".
Solution: Refer to Table 10 for register changes. Table 10 shows that CAPCON for EV-
A was changed to CAPCONA. Update the code to use CAPCONA.
– Bit field name has changed to align with the user’s guide:
Example error: struct "FOTPWAIT_BITS" has no field "OPTWAIT" Solution:
Solution: Refer to Table 11 for bit name changes. Table 11 shows that OPTWAIT was
changed to OTPWAIT. Update the code to use OTPWAIT.
– Register was removed and is no longer used.
Example: struct "DEV_EMU_REGS" has no field "M0RAMDFT”
Solution: Refer to Table 10 for register changes. Table 10 indicates that this register
was removed and no longer needs to be initialized. Remove the code that initializes this
register.
– Register bit-field definitions for a register were removed:
Example: expression must have struct or union type
This error occurs when the .bit or the .all is used to access a register that no longer has
a union defined.
Solution: Examine the source code that caused this error. For example:
SysCtrlRegs.SCSR.all = 0x0002;
31
V1.20 Quick Start Readme
Refer to Table 11 for bit name changes. Table 11 indicates the bit field was removed for
this register because of the sensitivity of other bits to read-modify-write instructions.
Modify the code to not use .bit or .all:
SysCtrlRegs.SCSR = 0x0002;
– Register bit-field definitions for a register were added:
Example: a value of type "int" cannot be assigned to an entity of
type "union PLLCR_REG"
This error occurs when a register that has a bit-field definition is accessed without
specifying the .bit or the .all union member.
Solution: Look at the source that caused the error. For example:
SysCtrlRegs.PLLCR = 0x000A;
Refer to Table 11 for bit name changes. Table 11 indicates that bit fields were added for
this register. The solution is to access the register using the .all union member:
SysCtrlRegs.PLLCR.all = 0x000A;
32
SPRC097 Version 1.20 Quick Start Readme
33
V1.20 Quick Start Readme
Table 11. Summary of Bit-Name Changes from V.58 to V1.00 and Newer
Bit Name
Peripheral Register Old New Comment
AdcRegs
ADCMAXCONV MAX_CONV MAX_CONV1 Field was split into two parts:
MAX_CONV2 MAX_CONV1 0:3 &
MAX_CONV2 4:6
ADCTRL1 rsvd2 SEQ_OVRD New Feature as of Rev C
CpuTimerRegs
TCR OUTSTS reserved Feature not implemented on F281x
FORCE reserved Feature not implemented on F281x
POL reserved Feature not implemented on F281x
TOG reserved Feature not implemented on F281x
FRCEN reserved Feature not implemented on F281x
PWIDTH reserved Feature not implemented on F281x
DevEmuRegs
DEVICEID PARTID reserved Feature no longer supported
M0RAMDFT - - Removed. Init no longer needed.
M1RAMDFT - - Removed. Init no longer needed.
L0RAMDFT - - Removed. Init no longer needed.
L1RAMDFT - - Removed. Init no longer needed.
H0RAMDFT - - Removed. Init no longer needed.
EcanaRegs
CANMC SCM SCB Alignment with user’s guide.
LNTM TCC Alignment with user’s guide.
LNTC MBCC Alignment with user’s guide.
CANBTC TSEG2 TSEG2REG Alignment with user’s guide.
TSEG1 TSEG1REG Alignment with user’s guide.
SJW SJWREG Alignment with user’s guide.
ERM reserved Feature not implemented on F281x
ERM reserved Alignment with user’s guide.
BRP BRPREG
CANGIFO TCOIFO TCOFO Alignment with user’s guide.
MAIFO MTOFO Alignment with user’s guide.
CANGIM SIL GIL Alignment with user’s guide.
TCOIM TCOM Alignment with user’s guide.
MAIM MTOM Alignment with user’s guide.
CANGIF1 TCOIF1 TCOF1 Alignment with user’s guide.
MAIF1 MTOF1 Alignment with user’s guide.
34
SPRC097 Version 1.20 Quick Start Readme
Table 10 Continued - Summary of Bit-Name Changes from V.58 to V1.00 and Newer
Bit Name
Peripheral Register Old New Comment
EcanaRegs continued
CANTIOC TXIN Reserved Feature not implemented
TXOUT Reserved Feature not implemented
TXDIR Reserved Feature not implemented
CANRIOC RXIN Reserved Feature not implemented
RXOUT Reserved Feature not implemented
RXDIR Reserved Feature not implemented
CANMSGID MSGID_L EXTMSGID_L Alignment with user’s guide.
MSGID_H EXTMSGID_H Due to 16-bit size limit for bit-fields,
STDMSGID this was broken into two parts
EvaRegs
GPTCONA TCOMPOE TCMPOE Alignment with user’s guide.
rsvd2 T1CTRIPE Correction
T2CTRIPE
EXTCONA QEPIQEL QEPIQUAL Correction
COMCONA rsvd C1TRIPE Correction
C2TRIPE
C3TRIPE
FCMP1OE
FCMP2OE
FCMP3OE
CAPCONA CAPQEPN CAP12EN Alignment with user’s guide.
EvbRegs
GPTCONB TCOMPOE TCMPOE Alignment with user’s guide.
T1CTRIP T3CTRIPE Correction
T2CTRIP T4CTRIPE Correction
EXTCONB QEPIQEL QEPIQUAL Correction
COMCONB rsvd3 C4TRIPE Correction
C5TRIPE
C6TRIPE
FCMP4OE
FCMP5OE
FCMP6OE
CAPCONB CAPQEPN CAP45EN Alignment with user’s guide.
35
V1.20 Quick Start Readme
Table 10 Continued - Summary of Bit-Name Changes from V.58 to V1.00 and Newer
Bit Name
Peripheral Register Old New Comment
McbspaRegs
XCERA XCEA0-XCEA15 XCERA0-XCERA15 Alignment with user’s guide.
XCERB XCEB0-XCEB15 XCERB0-XCERB15 Alignment with user’s guide.
XCERC XCEC0-XCEC15 XCERC0-XCERC15 Alignment with user’s guide.
XCERD XCED0-XCED15 XCERD0-XCERD15 Alignment with user’s guide.
XCERE XCEE0-XCEE15 XCERE0-XCERE15 Alignment with user’s guide.
XCERC XCEF0-XCEF15 XCERF0-XCERF15 Alignment with user’s guide.
XCERG XCEG0-XCEG15 XCERG0-XCERG15 Alignment with user’s guide.
MFFCT TXDLY FFTXDLY Alignment with user’s guide.
MFFRX IL RXFFIL Alignment with user’s guide
INT_CLR RXFFINT_CLEAR Alignment with user’s guide
INT RXFFINT_FLAG Alignment with user’s guide
ST RXFFST Alignment with user’s guide
RRESET RXFIFO_RESET Alignment with user’s guide
OVF_CLR RXFFOVF_CLEAR Alignment with user’s guide
OVF RXFFOVF_FLAG Alignment with user’s guide
MFFTX IL TXFFIL Alignment with user’s guide
INT_CLR TXFFINT_CLEAR Alignment with user’s guide
INT TXFFINT_FLAG Alignment with user’s guide
ST TXFFST Alignment with user’s guide
XRESET TXFIFO_RESET Alignment with user’s guide
SPCR1 REMPTY RFULL Correction
SRGR2 GYSNC GSYNC Correction
CLKSP resvd Correction
SciaRegs
SCIRXST RXERR RXERROR Alignment with user’s guide.
SCIFFTX resvd SCIRST Correction
SCIFFRX RSOVF_CLR RXFFOVRCLR Alignment with user’s guide.
ScibRegs
SCIRXST RXERR RXERROR Alignment with user’s guide.
SCIFFTX resvd SCIRST Correction
SCIFFRX RSOVF_CLR RXFFOVRCLR Alignment with user’s guide.
SpiaRegs
SPIFFTX TXFFINTINTCLR TSFFINTCLR Alignment with user’s guide.
TXFIFORESET TXFIFO Alignment with user’s guide.
rsvd SPIFFENA Correction
SPIRST
SPICCR RESET SPISWRESET Alignment with user’s guide.
SPICTL OVERRUN OVERRUNINTENA Alignment with user’s guide.
36
SPRC097 Version 1.20 Quick Start Readme
Table 10 Continued - Summary of Bit-Name Changes from V.58 to V1.00 and Newer
Bit Name
Peripheral Register Old New Comment
SysCtrlRegs
PCLKCR SCIENCLKA SCIAENCLK Alignment with user’s guide.
SCIENCLKB SCIBENCLK Alignment with user’s guide.
SCSR WDOVERRIDE Register bit fields were removed due
WDENINT to WDOVERRIDE sensitivity to read-
modify-write instructions
Use: SysCtrlRegs.SCSR = MASK
LPMCR0 - LPM Bit fields added. Use .all or .bit to
QUALSTDBY access this register.
LPMCR1 - XINT1 Bit fields added. Use .all or .bit to
XNMI access this register.
WDINT etc…
PLLCR DIV Bit fields added. Use .all or .bit to
access this register.
FlashRegs
FBANKWAIT OPTWAIT OTPWAIT Typo correction
37
V1.20 Quick Start Readme
8 Packet Contents:
This section lists all of the files included in the release.
38
SPRC097 Version 1.20 Quick Start Readme
8.1.2 DSP281x Header Files – Peripheral Bit-Field and Register Structure Definition
Files
The following files define the bit-fields and register structures for each of the peripherals on the
281x devices. These files are automatically included in the project by including
DSP281x_Device.h. Refer to section 4.2 for more information on incorporating the header files
into a new or existing project.
Table 13. DSP281x Header File Bit-Field & Register Structure Definition Files
File Location Description
DSP281x_Adc.h DSP281x_headers\include ADC register structure and bit-field definitions.
DSP281x_CpuTimers.h DSP281x_headers\include CPU-Timer register structure and bit-field definitions.
DSP281x_DevEmu.h DSP281x_headers\include Emulation register definitions
DSP281x_ECan.h DSP281x_headers\include eCAN register structures and bit-field definitions.
DSP281x_Ev.h DSP281x_headers\include Event manager (EV) register structures and bit-field
definitions.
DSP281x_Gpio.h DSP281x_headers\include General Purpose I/O (GPIO) register structures and
bit-field definitions.
DSP281x_Mcbsp.h DSP281x_headers\include McBSP register structure and bit-field definitions.
DSP281x_PieCtrl.h DSP281x_headers\include PIE control register structure and bit-field definitions.
DSP281x_PieVect.h DSP281x_headers\include Structure definition for the entire PIE vector table.
DSP281x_Sci.h DSP281x_headers\include SCI register structure and bit-field definitions.
DSP281x_Spi.h DSP281x_headers\include SPI register structure and bit-field definitions.
DSP281x_SysCtrl.h DSP281x_headers\include System register definitions. Includes Watchdog, PLL,
CSM, Flash/OTP, Clock registers.
DSP281x_Xintf.h DSP281x_headers\include External memory interface (XINTF) register structure
and bit-field definitions.
DSP281x_XIntrupt.h DSP281x_headers\include External interrupt register structure and bit-field
definitions.
39
V1.20 Quick Start Readme
8.1.4 Variable Names and Data Sections
This section is a summary of the variable names used and data sections allocated by the
DSP281x_headers\source\DSP281x_GlobalVariableDefs.c file.
40
SPRC097 Version 1.20 Quick Start Readme
In addition, the following files are included for software prioritization of interrupts. These files are
used in place of those above when additional software prioritization of the interrupts is required.
Refer to the example and documentation in DSP281x_examples\sw_prioritized_interrupts for
more information.
Table 16. Software Prioritized Interrupt PIE Block Specific Support Files
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.
41
V1.20 Quick Start Readme
8.2.3 Utility Function Source Files
42
SPRC097 Version 1.20 Quick Start Readme
43
V1.20 Quick Start Readme
// Make this really long since we are going through all
// the baud rates.
44
SPRC097 Version 1.20 Quick Start Readme
g) Example_281xSci_FFDLB_int.c – fixed baud rate calculation defines at the top of file by
adding: #define LSPCLK_FREQ CPU_FREQ/4 and fixing the SCI baud rate period
formula such that: #define SCI_PRD LSPCLK_FREQ/((SCI_FREQ*8)-1).
h) DSP281x_Mcbsp.c – Updated with new initialization functions for Mcbsp GPIO, data
lengths, and general initialization for digital loopback mode. Also added #define for SRG
cycle delay required in initialization routine.
i) DSP281x_ECan.c – Removed system initialization functions, corrected notation for
TSEGn fields in the comments section for bit timing configuration, and implemented
reads/writes using shadow registers where required.
j) DSP281x_SysCtrl.c – Added CsmUnlock() function which allows user to unlock the
CSM in code, if desired.
k) DSP281x_GlobalPrototypes.h – Added extern function prototype for CsmUnlock().
Added extern function prototype for new Mcbsp functions in DSP281x_Mcbsp.c. Also,
declared extern function prototype for usDelay.asm here.
l) Mcbsp examples updated to utilize McBSP GPIO initialization function and McBSP
initialization functions in the new DSP281x_Mcbsp.c.
m) Example_281xMcBSP_FFDLB_int.c – For clarity, updated initialization writes to RCR2
and XCR2 – “132” part of 0x1321 is “don’t care” because there is no phase 2 in this
configuration.
n) Example_281xSWPrioritizedDefaultIsr.c – Fixed numerous typos so that priorities are
set properly in the ISR’s.
o) Example_281xECanBack2Back.c – Incorporated updates to DSP281x_ECan.c in
example. Also added a note about CanDoubleWrite and CanDoubleRead when user
incorporates code into an application which does not use self-test mode.
p) Added sci_echoback example which transmits and echoes characters through SCI-A via
Hyperterminal on the PC.
q) F2812_EzDSP_RAM_lnk.cmd – changed line from:
// For BIOS applications add: DSP281x_Headers_nonBIOS.cmd
to the below:
// For BIOS applications add: DSP281x_Headers_BIOS.cmd
10 Errata:
This section lists known typos in the header files which have not been updated to prevent
incompatibilities with code developed using earlier versions of the header files.
a) DSP281x_I2C.h:
Details— When the C-header files are included in an assembly project, the assembler
views the AL (Arbitration Lost) bit in both the I2CIER and the I2CSTR structures as
reserved words and issues an error.
45
V1.20 Quick Start Readme
Workaround— When including the C-header files in an assembly project, rename the
AL bits to ARBL in DSP281x_I2C.h as follows to prevent conflicts with the assembler:
//----------------------------------------------------
// I2C interrupt mask register bit definitions */
struct I2CIER_BITS { // bits description
Uint16 ARBL:1; // 0 Arbitration lost interrupt
Uint16 NACK:1; // 1 No ack interrupt
Uint16 ARDY:1; // 2 Register access ready interrupt
Uint16 RRDY:1; // 3 Recieve data ready interrupt
Uint16 XRDY:1; // 4 Transmit data ready interrupt
Uint16 SCD:1; // 5 Stop condition detection
Uint16 AAS:1; // 6 Address as slave
Uint16 rsvd:9; // 15:7 reserved
};
//----------------------------------------------------
// I2C status register bit definitions */
struct I2CSTR_BITS { // bits description
Uint16 ARBL:1; // 0 Arbitration lost interrupt
Uint16 NACK:1; // 1 No ack interrupt
Uint16 ARDY:1; // 2 Register access ready interrupt
Uint16 RRDY:1; // 3 Recieve data ready interrupt
Uint16 XRDY:1; // 4 Transmit data ready interrupt
Uint16 SCD:1; // 5 Stop condition detection
Uint16 rsvd1:2; // 7:6 reserved
Uint16 AD0:1; // 8 Address Zero
Uint16 AAS:1; // 9 Address as slave
Uint16 XSMT:1; // 10 XMIT shift empty
Uint16 RSFULL:1; // 11 Recieve shift full
Uint16 BB:1; // 12 Bus busy
Uint16 NACKSNT:1; // 13 A no ack sent
Uint16 SDIR:1; // 14 Slave direction
Uint16 rsvd2:1; // 15 reserved
};
b) The following table lists typos in the header files which were not corrected to preserve
compatibility with previous versions of the header files.
46
SPRC097 Version 1.20 Quick Start Readme
BYTE7 BYTE5
BYTE8 BYTE4
PieCtrlRegs
PIECTRL PIECRTL PIECTRL Typo
SciaRegs, ScibRegs
SCIFFTX TXFFILIL TXFFIL Typo
TXINTCLR TXFFINTCLR Align with user guide.
SCIFFRX RXFIFST RXFFST Typo – Also corrected in
user guide
47