TEXAS INSTRUMENTS 2802x Technical data

2802x C/C++ Header Files and Peripheral Examples Quick Start
Version 1.25
December 18, 2009
SPRC992
2802x C/C++ Header Files and Peripheral Examples
Quick Start
1 Device Support:............................................................................................................................ 2
2 Introduction: ................................................................................................................................. 2
3 Understanding The Peripheral Bit-Field Structure Approach ................................................... 6
4 Peripheral Example Projects ....................................................................................................... 7
4.1.1 Getting Started in Code Composer Studio v4.0+......................................................... 7
4.2.1 Source Code............................................................................................................. 14
4.2.2 Linker Command Files .............................................................................................. 14
5 Steps for Incorporating the Header Files and Sample Code ................................................... 23
6 Troubleshooting Tips & Frequently Asked Questions............................................................. 30
6.1.1 Registers with multiple flag bits in which writing a 1 clears that flag........................... 33
6.1.2 Registers with Volatile Bits........................................................................................ 33
7 Migration Tips for moving from the TMS320x280x or TMS320x281x header files to the
8 Packet Contents:........................................................................................................................ 35
8.1.1 DSP2802x Header Files – Main Files........................................................................ 35
8.1.2 DSP2802x Header Files – Peripheral Bit-Field and Register Structure Definition
Files .......................................................................................................................... 36
8.1.3 Variable Names and Data Sections........................................................................... 37
8.2.1 Peripheral Interrupt Expansion (PIE) Block Support .................................................. 38
8.2.2 Peripheral Specific Files............................................................................................ 39
8.2.3 Utility Function Source Files...................................................................................... 40
8.2.4 Example Linker .cmd files ......................................................................................... 40
8.2.5 Example Library .lib Files .......................................................................................... 41
9 Detailed Revision History: ......................................................................................................... 42
1
V1.25 Quick Start Readme
1 Device Support:
This software package supports 2802x devices. This includes the following: TMS320F28027, TMS320F28026, TMS320F28023, TMS320F28022, TMS320F28021, TMS320F28020, and TMS320F280200.
Throughout this document, TMS320F28027, TMS320F28026, TMS320F28023, TMS320F28022, TMS320F28021, TMS320F28020, and TMS320F280200 are abbreviated as F28027, F28026, F28023, F28022, F28021, F28020, and F280200 respectively.
2 Introduction:
The 2802x C/C++ peripheral header files and example projects facilitate writing in C/C++ Code for the Texas Instruments TMS320x2802x 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™† v4.0+ projects for a ‘2802x 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 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 2802x C/C++ peripheral header files.
Overview of the included peripheral example projects.
Steps for integrating the peripheral header files into a new or existing project.
Troubleshooting tips and frequently asked questions.
Migration tips for users moving from the DSP280x header files to the DSP2802x header
files.
Code Composer Studio is a trademark of Texas Instruments (www.ti.com).
2
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 2802x 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.
2.1 Revision History
Version 1.25
This version includes minor corrections to the header files and examples. The most
notable change is that gel files and cmd linker files for the 280200 devices now include 1K additional L0 RAM. A detailed revision history can be found in Section 9.
Version 1.21b
This version update only updates the V1.21 Quick Start Readme to adjust wording for
the controlSUITE software package. No changes to the header file and peripheral example code were made.
Version 1.21
V1.25 Quick Start Readme
This version includes minor corrections and comment fixes to the header files and
examples. A detailed revision history can be found in Section 9.
Version 1.20
This version includes corrections and comment fixes to the header files and examples.
It adds examples pertaining to the ADC temperature sensor and compensation of the oscillator frequency over temperature, and it also fixes an error in the SFO_TI_Build_V6.lib library in the new SFO_TI_Build_V6b.lib library . A detailed revision history can be found in Section 9.
Version 1.10
This version includes corrections and comment fixes to the header files and examples,
adds 3 new 2802x devices – 28021, 28020, and 280200 - , deletes 2 2802x devices – 28024 and 28025 - and also adds a separate example folder, DSP2802x_examples_ccsv4, with examples supported by the Eclipse-based Code Composer Studio v4. A detailed revision history can be found in Section 9.
Version 1.00
This version is the first release of the 2802x header files and examples.
3
V1.25 Quick Start Readme
2.2 Where Files are Located (Directory Structure)
As installed, the 2802x C/C++ Header Files and Peripheral Examples is partitioned into a well-defined directory
structure.
Table 1 describes the contents of the main directories used by DSP2802x header files and peripheral examples:
Table 1. DSP2802x Main Directory Structure
Directory Description
<base> Base install directory. For the rest of this document <base> will be omitted
from the directory names. <base>\doc Documentation including the revision history from the previous release. <base>\DSP2802x_headers Files required to incorporate the peripheral header files into a project .
The header files use the bit-field structure approach described in Section
3.
Integrating the header files into a new or existing project is described in
Section 5. <base>\DSP2802x_examples_ccsv4 Example Code Composer Studio v4.0+ projects. These example projects
illustrate how to configure many of the on-chip peripherals. An overview of
the examples is given in Section 4. <base>DSP2802x_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 8.
Under the DSP2802x_headers and DSP2802x_common directories the source files are further broken down into sub-directories each indicating the type of file. Table 2 lists the sub-
4
V1.25 Quick Start Readme
directories and describes the types of files found within each:
Table 2. DSP2802x Sub-Directory Structure
Sub-Directory Description
DSP2802x_headers\cmd Linker command files that allocate the bit-field structures described in Section 3. DSP2802x_headers\source Source files required to incorporate the header files into a new or existing
project.
DSP2802x_headers\include Header files for each of the on-chip peripherals.
DSP2802x_common\cmd Example memory command files that allocate memory on the devices. DSP2802x_common\include Common .h files that are used by the peripheral examples. DSP2802x_common\source Common .c files that are used by the peripheral examples. DSP2802x_common\lib Common library (.lib) files that are used by the peripheral examples. DSP2802x_common\gel\ccsv4 Code Composer Studio v4.x GEL files for each device. These are optional.
5
V1.25 Quick Start Readme
3 Understanding The Peripheral Bit-Field Structure Approach
The following application note includes useful information regarding the bit-field peripheral structure approach used by the header files and examples.
This method is compared to traditional #define macros and topics of code efficiency and special case registers are also addressed. The information in this application note is important to understand the impact using bit fields can have on your application code.
Programming TMS320x28xx and 28xxx Peripherals in C/C++ (SPRAA85)
6
V1.25 Quick Start Readme
4 Peripheral Example Projects
This section describes how to get started with and configure the peripheral examples included in the 2802x Header Files and Peripheral Examples software package.
4.1 Getting Started
4.1.1 Getting Started in Code Composer Studio v4.0+
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 ‘2802x example projects are built for the ‘28027 device. If you
are using another 2802x 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 ‘2802x CPU-Timer example project directory, follow the following steps:
a. In Code Composer Studio v 4.x: Project->Import Existing CCS/CCE Eclipse Project.
b. Next to “Select Root Directory”, browse to the CPU Timer example directory:
DSP2802x_examples_ccsv4\cpu_timer. Select the Finish button.
This will import/open the project in the CCStudio v4 C/C++ Perspective project window.
3. Edit DSP28_Device.h
Edit the DSP2802x_Device.h file and make sure the appropriate device/package combination is selected. By default the 28027 PT package is selected.
/******************************************************************** * DSP2802x_headers\include\DSP2802x_Device.h ********************************************************************/
#define TARGET 1 //--------------------------------------------------------------------------­// User To Select Target Device:
define DSP28_280200PT 0 #define DSP28_280200DA 0
#define DSP28_28020PT 0 #define DSP28_28020DA 0
#define DSP28_28021PT 0 #define DSP28_28021DA 0
7
V1.25 Quick Start Readme
#define DSP28_28022PT 0 #define DSP28_28022DA 0
#define DSP28_28023PT 0 #define DSP28_28023DA 0
#define DSP28_28026PT 0 #define DSP28_28026DA 0
#define DSP28_28027PT TARGET #define DSP28_28027DA 0
4. Edit DSP2802x_Examples.h
Edit DSP2802x_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 60Mhz SYSCLKOUT frequency.
/******************************************************************** * DSP2802x_common\include\DSP2802x_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 12 //#define DSP28_PLLCR 11 //#define DSP28_PLLCR 10 //#define DSP28_PLLCR 9 //#define DSP28_PLLCR 8 //#define DSP28_PLLCR 7 //#define DSP28_PLLCR 6 //#define DSP28_PLLCR 5 //#define DSP28_PLLCR 4 //#define DSP28_PLLCR 3 //#define DSP28_PLLCR 2 //#define DSP28_PLLCR 1 //#define DSP28_PLLCR 0 // (Default at reset) PLL is bypassed in this mode //----------------------------------------------------------------------------
In DSP2802x_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 60 Mhz SYSCLKOUT. If you have a 50 Mhz device or a 40 MHz device you will need to adjust these settings accordingly.
8
V1.25 Quick Start Readme
/******************************************************************** * DSP2802x_common\include\DSP2802x_Examples.h ********************************************************************/ …… #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) //#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT) ……
In DSP2802x_Examples.h the target device chosen in DSP2802x_Device.h also specifies the maximum SYSCLKOUT frequency (60 MHz, 50 Mhz, or 40 MHz) by setting it to 1 and the other to 0 via compiler directives. This value is used by those examples with timing dependent code (i.e. baud rates or other timing parameters) to determine whether 60MHz code, 50 Mhz code, or 40MHz code should be run.
The default value is for 60Mhz SYSCLKOUT for the ‘28027 device. If you have selected a 50 Mhz device or a 40 MHz device in DSP2802x_Device.h, the frequency settings are adjusted accordingly. If you intend to run examples which use these definitions at a different frequency, then the timing parameters in those examples must be directly modified accordingly regardless of the setting here.
/******************************************************************** * DSP2802x_common\include\DSP2802x_Examples.h ********************************************************************/ …… #if (DSP28_28026PT||DSP28_28026DA||DSP28_28027PT||DSP28_28027DA) // 28026||28027 devices only #define CPU_FRQ_60MHZ 1 // 60 Mhz CPU Freq (10 MHz input clock) #define CPU_FRQ_50MHZ 0 #define CPU_FRQ_40MHZ 0 #elif (DSP28_28023PT||DSP28_28023DA||DSP28_28022PT||DSP28_28022DA) // 28023||28023 devices #define CPU_FRQ_60MHZ 0 #define CPU_FRQ_50MHZ 1 // 50 MHz CPU Freq (10 MHz input clock) #define CPU_FRQ_40MHZ 0 #else // 28021||28020||280200 devices #define CPU_FRQ_60MHZ 0 #define CPU_FRQ_50MHZ 0 #define CPU_FRQ_40MHZ 1 // 40 MHz CPU Freq (10 MHz input clock) #endif//----------------------------------------------------------------------------
5. Review the comments at the top of the main source file: Example_2802xCpuTimer.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 of each example. 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.
9
V1.25 Quick Start Readme
Perform any hardware setup indicated by the comments in the main source. The CPU­Timer example only requires that the hardware be setup for “Boot to SARAM” 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 your reference. Table 4 and Table 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 configuring the boot mode pins. For more information on the ‘2802x boot modes refer to the device specific Boot ROM Reference Guide.
Table 3. 2802x Boot Mode Settings
GPIO37
TDO
X X 1 EMU Mode 0 0 0 Parallel I/O 0 1 0 SCI 1 0 0 Wait 1 1 0 “Get Mode”
GPIO34
CMP2OUT
TRSTn
Mode
Table 4. 2802x EMU Boot Modes (Emulator Connected)
EMU_KEY
0x0D00
!= 0x55AA x Wait
0x55AA
EMU_BMODE
0x0D01
0x0000 Parallel I/O
0x0001 SCI 0x0002 Wait 0x0003 Get Mode 0x0004 SPI 0x0005 I2C 0x0006 OTP 0x0007 Wait
0x0008 Wait 0x000A Boot to RAM 0x000B Boot to FLASH
Other Wait
Boot Mode Selected
10
Table 5. 2802x GET Boot Modes (Emulator Disconnected)
OTP_KEY OTP_BMODE Boot Mode Selected
V1.25 Quick Start Readme
0x3D7BFE 0x3D7BFF
!= 0x55AA x Get Mode - Flash
0x55AA
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 the desired EMU boot mode value to EMU_BMODE at 0x0D01 via the debugger window according to Table 4. The 2802x gel files in the DSP2802x_common/gel/ directory have a GEL function – EMU Boot Mode Select -> EMU_BOOT_SARAM() which performs the debugger write to boot to “SARAM” mode when called.
When the emulator is not connected for debugging:
0x0001 Get Mode - SCI 0x0003 Get Mode – Flash 0x0004 Get Mode - SPI 0x0005 Get Mode - I2C 0x0006 Get Mode - OTP
Other Get Mode - Flash
SCI or Parallel I/O boot mode can be selected directly via the GPIO pins, or OTP_KEY at address 0x3D7BFE and OTP_BMODE at address 0x3D7BFF can be programmed for the desired boot mode per Table 5.
7. Build and Load the code
Once any hardware configuration has been completed, in Code Composer Studio v4, go to Target->Debug Active Project.
This will open the “Debug Perspective” in CCSv4, build the project, load the .out file into the 28x device, reset the part, and execute code to the start of the main function. By default, in Code Composer Studio v4, every time Debug Active Project is selected, the code is automatically built and the .out file loaded into the 28x 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 4.2 and 4.3 describe the structure and flow of the examples in more detail.
11
V1.25 Quick Start Readme
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.
12
4.2 Example Program Structure
V1.25 Quick Start Readme
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.
/******************************************************************** * DSP2802x_examples_ccsv4\cpu_timer\Example_2802xCpuTimer.c ********************************************************************/
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
DSP28x_Project.h
This header file includes DSP2802x_Device.h and DSP2802x_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>\DSP2802x_common\include directory.
DSP2802x_Device.h
This header file is required to use the 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 <base>\DSP2802x_headers\include directory.
13
V1.25 Quick Start Readme
DSP2802x_Examples.h
This header file defines parameters that are used by the example code. This file is not required to use just the DSP2802x peripheral header files but is required by some of the common source files. This file is found in the <base>\DSP2802x_common\include directory.
4.2.1 Source Code
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.
DSP2802x_GlobalVariableDefs.c
Any project that uses the DSP2802x 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>\DSP2802x_headers\source directory.
Example specific source code:
Files that are specific to a particular example have the prefix Example_2802x in their filename. For example Example_2802xCpuTimer.c is specific to the CPU Timer example and not used for any other example. Example specific files are located in the <base>\DSP2802x_examples_ccsv4\<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 DSP2802x_common\source directory. Users may choose to incorporate none, some, or the entire shared source into their own new or existing projects.
4.2.2 Linker Command Files
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 DSP2802x peripheral header files.
Memory block linker allocation:
The linker files shown in 0 are used to assign sections to memory blocks on the device. These linker files are located in the <base>\DSP2802x_common\cmd directory. Each example will use one of the following files depending on the memory used by the example.
14
V1.25 Quick Start Readme
Table 6. Included Memory Linker Command Files
Memory Linker Command
File Examples
28027_RAM_lnk.cmd DSP2802x_common\cmd 28027 memory linker command file.
28026_RAM_lnk.cmd DSP2802x_common\cmd 28026 SARAM memory linker command
28023_RAM_lnk.cmd DSP2802x_common\cmd 28023 SARAM memory linker command
28022_RAM_lnk.cmd DSP2802x_common\cmd 28022 SARAM memory linker command
28021_RAM_lnk.cmd DSP2802x_common\cmd 28021 SARAM memory linker command
28020_RAM_lnk.cmd DSP2802x_common\cmd 28020 SARAM memory linker command
280200_RAM_lnk.cmd DSP2802x_common\cmd 280200 SARAM memory linker command
F28027.cmd DSP2802x_common\cmd F28027 memory linker command file.
F28026.cmd DSP2802x_common\cmd F28026 memory linker command file. F28023.cmd DSP2802x_common\cmd F28023 memory linker command file. F28022.cmd DSP2802x_common\cmd F28022 memory linker command file. F28021.cmd DSP2802x_common\cmd F28021 memory linker command file. F28020.cmd DSP2802x_common\cmd F28020 memory linker command file. F280200.cmd DSP2802x_common\cmd F280200 memory linker command file.
Location Description
Includes all of the internal SARAM blocks on 28027 device. “RAM” linker files do not include flash or OTP blocks.
file.
file.
file.
file.
file.
file.
Includes all Flash, OTP and CSM password protected memory locations.
Header file structure data section allocation:
Any project that uses the header file peripheral structures must include a linker command file that assigns the peripheral register structure data sections to the proper memory location. These files are described in Table 7.
Table 7. DSP2802x Peripheral Header Linker Command File
Header File Linker Command File Location Description
DSP2802x_Headers_nonBIOS.cmd DSP2802x_headers\cmd Linker .cmd file to assign the header file
variables in a non-BIOS project. This file must be included in any non-BIOS project that uses the header files. Refer to section 5.2.
DSP2802x_Headers_nonBIOS.cmd DSP2833x_headers\cmd Linker .cmd file to assign the header file
variables in a non-BIOS project. This file must be included in any non-BIOS project that uses the header files. Refer to section 5.2.
15
Loading...
+ 32 hidden pages