Tic2000 User's Guide
Tic2000 User's Guide
User’s Guide
www.mathworks.com Web
comp.soft-sys.matlab Newsgroup
www.mathworks.com/contact_TS.html Technical Support
508-647-7000 (Phone)
508-647-7001 (Fax)
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
November 2003 Online only New for Version 1.0 (Release 13SP1+)
June 2003 Online only New for Version 1.1 (Release 14)
October 2004 Online only Revised for Version 1.1.1 (Release 14SP1)
December 2004 Online only Revised for Version 1.2 (Release 14SP1+)
March 2005 Online only Revised for Version 1.2.1 (Release 14SP2)
September 2005 Online only Revised for Version 1.3 (Release 14SP3)
March 2006 Online only Revised for Version 2.0 (Release 2006a)
September 2006 Online only Revised for Version 2.1 (Release 2006b)
March 2007 Online only Revised for Version 2.2 (Release 2007a)
September 2007 Online only Revised for Version 2.3 (Release 2007b)
March 2008 Online only Revised for Version 3.0 (Release 2008a)
October 2008 Online only Revised for Version 3.1 (Release 2008b)
March 2009 Online only Revised for Version 3.2 (Release 2009a)
September 2009 Online only Revised for Version 4.0 (Release 2009b)
March 2010 Online only Revised for Version 4.1 (Release 2010a)
September 2010 Online only Revised for Version 4.2 (Release 2010b)
Contents
Getting Started
1
Product Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Product Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
v
Using the c2000lib Blockset . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
Hardware Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
Starting the c2000lib Library . . . . . . . . . . . . . . . . . . . . . . . . 1-30
Setting Up the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-30
Adding Blocks to the Model . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Generating Code from the Model . . . . . . . . . . . . . . . . . . . . . 1-35
vi Contents
Using the IQmath Library
4
About the IQmath Library . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Common Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
vii
Placing Additional Code or Data on Unused Flash
Sectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8
Block Reference
7
C280x (c280xlib) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
viii Contents
Blocks — Alphabetical List
8
Index
ix
x Contents
1
Getting Started
Product Overview
In this section...
“Introduction” on page 1-2
“Product Description” on page 1-2
Introduction
This chapter describes how to use Target Support Package™ software
to create and execute applications on Texas Instruments™ C2000™
microcontrollers. To use the targeting software, become familiar with creating
Simulink® models and with the basic concepts of using Real-Time Workshop®
for automatic code generation. For more information about these concepts,
refer to the “Real-Time Workshop” documentation.
Product Description
Use Target Support Package to deploy generated code for real-time execution
on embedded microprocessors, microcontrollers, and DSPs. Using Target
Support Package, you can integrate peripheral devices and real-time
operating systems with the algorithms created using Embedded MATLAB™,
Simulink®, and Stateflow®. You can deploy the resulting executable onto
embedded hardware for on-target rapid prototyping, real-time performance
analysis, and field production.
1-2
Setting Up and Configuring
System Requirements
For detailed information about the software and hardware required to use
Target Support Package software, refer to the Target Support Package system
requirements areas on the MathWorks® Web site:
Supported Hardware
For a list of supported hardware, visit
http://www.mathworks.com/products/target-package/supportedio.html.
The System Requirements Web page describes where you can obtain the
additional third-party software, and when available, provides links for
downloading that software.
1-3
1 Getting Started
5 If you are using a Spectrum Digital board, download and install the
matching Spectrum Digital Driver.
7 If you are going to program flash memory with stand-alone code, download
the TI Flash API for your target processor.
1 In CCS, open Help > About > Component manager > Build tools >
TMS320C28XX and select (check) C2000 Code Generation Tools.
c2000lib
1-4
Setting Up and Configuring
If you do not see the listed libraries, or MATLAB does not recognize the
command, install the Target Support Package software. Without the software,
you cannot use Simulink and Real-Time Workshop software to develop
applications targeted to the TI boards.
To verify that Code Composer Studio (CCS) is present on your machine, enter
this command at the MATLAB prompt:
ccsboardinfo
With CCS installed and configured, MATLAB returns a list of the boards that
CCS recognizes on your machine like the following example:
If MATLAB does not return information about any boards, revisit the
installation and setup instructions in your CCS documentation. If you have
not done so already, install the third-party “Board Support Packages” for
your boards.
As a final test, launch CCS to ensure that it starts up successfully. For Target
Support Package software to operate with CCS, the CCS IDE must be able to
run on its own.
Note For any model to work in the targeting environment, select the
discrete-time solver in the Solver pane of the Simulink Configuration
Parameters dialog box. Targeting does not work with continuous-time solvers.
To select the discrete-time solver, from the main menu in your model window,
select Simulation > Configuration Parameters. Then in the Solver pane,
set the Solver option to Discrete (no continuous states).
1-5
1 Getting Started
1-6
Code Composer Studio™
1-7
1 Getting Started
If you select int8 or uint8 in your model, your simulation runs with 8-bit
data, but in the generated code, that data will be represented as 16-bit. This
may cause instances where data overflow and wraparound occurs in the
simulation, but not in the generated code.
For example, to make the overflow behavior of the simulation and generated
code match for a Simulink Add block in your model, select Saturate on
integer overflow in that block.
1-8
Scheduling and Timing
Overview
Normally the code generated by Target Support Package software runs in
the context of a timer interrupt. Model blocks run in a periodical fashion
clocked by the periodical interrupt whose period is tied to the base sample
time of the model.
This execution scheduling model, however, is not flexible enough for many
systems, especially control and communication systems, which must respond
to external events in real time. Such systems require the ability to handle
various hardware interrupts in an asynchronous fashion.
Target Support Package software lets you model and generate code for such
systems by creating tasks driven by Hardware Interrupt blocks in addition to
the tasks that are left to be handled in the context of the timer interrupt.
The timer is configured so that the model’s base rate sample time corresponds
to the interrupt rate. The timer period and prescaler are calculated and set
up to ensure the desired rate as follows:
TimerPeriod
BaseRateSampleTime =
TimerClockSpeed
1-9
1 Getting Started
The minimum achievable base rate sample time depends on the model
complexity. The maximum value depends on the maximum timer period value
(232-1 for the F2812, F2808, and F28x35) and the CPU clock speed. The CPU
clock speed is 100 MHz for the F2808, and 150 MHz for the F2812 and F28335.
If all the blocks in the model inherit their sample time value, and no sample
time is explicitly defined, the default value is 0.2 s.
1-10
Scheduling and Timing
In the preceding figure, the Hardware Interrupt block is set to react on two
interrupts. Since only one Hardware Interrupt block is allowed in a model
and the output of this block is a vector of length two, you must connect the
Hardware Interrupt block to a Demux block to trigger the two function-call
subsystems. The function-call subsystems contain the blocks that are
executed asynchronously in the context of the hardware interrupt.
The following example shows how to build and configure a model to react on an
eCAN message using a hardware interrupt and an asynchronous scheduler:
1-11
1 Getting Started
2 On the eCAN Receive block dialog, check the box labeled Post interrupt
when message is received, as shown in the following figure.
3 Set the Sample Time of the eCAN Receive block to -1 since the block will
be triggered by the ISR, as shown in the preceding figure.
1-12
Scheduling and Timing
4 Add the C281x Hardware Interrupt block to your model, as shown in the
following figure.
5 The eCAN interrupt on C281x chips is on CPU line 9 and PIE line 5
for module 0. These parameters can be found in the C281x Hardware
Interrupt block, C281x Peripheral Interrupt Vector Values figure. Set the
hardware interrupt parameters CPU interrupt number(s): to 9, and PIE
interrupt number(s): to 5 as shown in the following figure.
1-13
1 Getting Started
1-14
Sharing General Purpose Timers between C281x Peripherals
Each PWM and QEP peripheral has access to only one timer, while each CAP
peripheral has access to two timers. In the PWM and QEP blocks, you can
set the Module option to A or B to determine which unique timer-peripheral
combination the block configures. By comparison, in the CAP block, you can
use the Time base option to select one of two timers for each CAP peripheral.
1-15
1 Getting Started
The PWM, QEP, CAP, and Timer blocks each provide independent access to
key timer registers. If the blocks in your model share a specific GP timer,
ensure that all the timer-related settings are compatible. If the peripheral
settings for a shared timer are not compatible, the software generates an
error when you update the model or generate code.
Example 1
The model contains Timer and CAP blocks that both use Timer 1 (GP Timer 1).
1-16
Sharing General Purpose Timers between C281x Peripherals
1-17
1 Getting Started
Both blocks have the same values for Timer prescaler and Counting
mode. However, each block has different values for Timer period. The
value of Timer period for Timer 1 is 65535 in the CAP block and 10000 in
the Timer block.
1-18
Sharing General Purpose Timers between C281x Peripherals
Since both blocks configure the same timer, and settings conflict, the software
generates an error when you update the model.
1-19
1 Getting Started
Example 2
The model contains QEP and CAP blocks that both use Timer 2. In the CAP
block, the Time base option shows which timer the block uses. In the QEP
block, setting Module to A configures the block to use QEP1–QEP2. GP
Timer Use for C281x Peripheral Blocks on page 1-15 shows that QEP1–QEP2
use Timer 2.
1-20
Sharing General Purpose Timers between C281x Peripherals
1-21
1 Getting Started
Currently, both blocks define different clock sources for Timer 2. The CAP
block uses Internal as a Clock source. The QEP block, which does not have
a configurable Clock source setting, uses the QEP circuit as a clock source.
If you build the model, the software generates the following error message.
1-22
Sharing General Purpose Timers between C281x Peripherals
To avoid generating errors when you build the model, change Clock source
in the CAP block to QEP device.
1-23
1 Getting Started
c2000lib
This opens the c2000lib Simulink blockset that includes libraries containing
blocks predefined for C2000 input and output devices. As needed, add the
blocks to your model. See “Using the c2000lib Blockset” on page 1-29 for an
example of how to use this library.
Create your real-time model for your application the same way you create any
other Simulink model. Select blocks to build your model from the following
sources or products:
• The Target Preferences library block (for setting target and application
preferences)
• The appropriate libraries in the c2000lib block library (for handling input
and output functions for on your target hardware)
• Real-Time Workshop software
• Discrete time blocks from Simulink
• Any other blockset that meets your needs and operates in the discrete
time domain
1-24
Overview of Creating Models for Targeting
Online Help
To get general help for Target Support Package software, use the help feature
in MATLAB. At the command prompt, type
help tic2000
to list the functions and block libraries included in Target Support Package
software. Or select Help > Full Product Family Help from the menu bar
in the MATLAB desktop. When you see the Contents in Help, select Target
Support Package.
From Workspace
1-25
1 Getting Started
1-26
Overview of Creating Models for Targeting
If you are setting your simulation parameters manually, you must make
at least the following two settings:
• You must specify discrete time by selecting Fixed-step and Discrete (no
continuous states) in the Solver pane of the Configuration Parameters
dialog box.
• You must also specify the appropriate version of the system target file in
the Real-Time Workshop pane. For Target Support Package software,
specify one of the following system target files, or click Browse and select
from the list of targets.
idelink_grt.tlc
idelink_ert.tlc
The associated template filename is automatically filled in.
The ERT target for Target Support Package software offers memory
management features that give you a way manage the performance of your
code while working with limited memory resources. For more information
1-27
1 Getting Started
During the same build operation, block parameter dialog box entries are
combined into a project file for CCS for your TI C2000 board. If you selected
the Build and execute build action in the configuration settings, the TI
cross-compiler builds an executable file. After automatically downloading the
executable file to the target, the build process runs the file on the board’s DSP.
Note After using the run-time Build option to generate and build code for
your application, you must perform the following reset sequence before you
can run that code on your board. If you want to rerun your application
manually once it has been generated, you must also use this procedure.
1-28
Using the c2000lib Blockset
Introduction
This section uses an example to demonstrate how to create a Simulink model
that uses Target Support Package blocks to target your board. The example
creates a model that performs PWM duty cycle control via pulse width change.
It uses the C2812 ADC block to sample an analog voltage and the C2812
PWM block to generate a pulse waveform. The analog voltage controls the
duty cycle of the PWM and you can observe the duty cycle change on the
oscilloscope. This model is also provided in the Demos library. The model in
the Demos library also includes a model simulation.
Hardware Setup
The following hardware is needed for this example:
2 Connect the output of PWM1 on the eZdsp F2812 to the analog input of
the oscilloscope.
1-29
1 Getting Started
c2000lib
This command open the c2000lib library blockset, which contains libraries of
blocks designed for targeting your board.
3 Right-click the Target Preferences block and select Add to a new model.
This opens a new model with the Target Preferences block in it.
1-30
Using the c2000lib Blockset
Note Generated code does not honor Simulink stop time from the
simulation. Stop time is interpreted as inf. To implement a stop in
generated code, you must put a Stop Simulation block in your model.
Note One Target Preferences block must be in each target model at the top
level. It does not connect to any other blocks, but stands alone to set the
Target Preferences for the model.
6 Use the Real-Time Workshop pane to set options for the real-time
model. Refer to your “Real-Time Workshop” documentation for detailed
information on the Real-Time Workshop pane options.
1-31
1 Getting Started
7 Use the Browse button to locate and select a target configuration file,
idelink_grt.tlc or idelink_ert.tlc. When you do this, Real-Time
Workshop software chooses the appropriate system target file, and make
command.
1-32
Using the c2000lib Blockset
2 Drag the C281x ADC block into your model. Double-click the ADC block
in the model and set Sample time to 64/80000. Use the default values
for all other fields. Refer to the C281x ADC reference page for information
on these fields.
1-33
1 Getting Started
3 Drag the C281x PWM block into your model. Double-click the PWM block
in the model and set the following parameters. Refer to the C281x PWM
reference page for information on these fields.
1-34
Using the c2000lib Blockset
5 Connect the ADC block to the Gain block and the Gain block to the PWM
block as shown:
You start the automatic code generation process from the Simulink model
window by clicking Generate code in the Real-Time Workshop pane of the
Configuration Parameters dialog. Other ways of starting the code generation
process are by clicking the Incremental Build button on the toolbar of
your model, or by pressing the keyboard shortcut, Ctrl+B, while your model
is open and in focus.
Note In CCS, you see your project with the files in place in the folder
structure.
1-35
1 Getting Started
1-36
2
Configuring Timing
Parameters for CAN Blocks
2-2
Setting Timing Parameters
1 Double click the Target Preferences block in your model. This opens the
Target Preferences dialog box.
For example, the Target Preferences block for the F2812 eZdsp, this dialog
box is shown in the following figure.
2-3
2 Configuring Timing Parameters for CAN Blocks
2-4
Setting Timing Parameters
The following sections describe the series of steps and rules that govern the
process of setting these timing parameters.
2-5
2 Configuring Timing Parameters for CAN Blocks
6 Estimate values of TSEG1 and TSEG2 that satisfy the following equation:
8 Iterate steps 4 through 7 until the values selected for TSEG1, TSEG2, and
BRP meet all of the criteria.
2-6
Setting Timing Parameters
The following illustration shows the relationship between the eCAN bit
timing parameters.
1 Set the BRP to 10. Then substitute the values of bit rate, BRP, and
SYSCLKOUT into the following equation, solving for BitTime:
2 Set the values of TSEG1 and TSEG2 to 8TQ and 6TQ respectively.
Substitute the values of BitTime from the previous equation, and the
chosen values for TSEG1 and TSEG2 into the following equation:
2-7
2 Configuring Timing Parameters for CAN Blocks
The following table provides common timing parameter settings for typical
values of Bit Rate and SYSCLKOUT = 150 MHz. This clock frequency is
the maximum for the C281x blocks.
The following table provides common timing parameter settings for typical
values of Bit Rate and SYSCLKOUT = 100 MHz. This clock frequency is the
maximum for the C280x/C28x3x blocks.
2-8
Parameter Tuning and Signal Logging
Overview
Target Support Package software supports parameter tuning and signal
logging either using Simulink external mode or with a third party calibration
tool. In both cases the model must include a CAN Calibration Protocol block.
External mode is supported using the CAN Calibration Protocol block and
ASAP2 interface. The CAN Calibration Protocol block is used to communicate
with the target, download parameter updates, and upload signal information.
The ASAP2 interface is used to get information about where in the target
memory a parameter or signal lives.
Note You must configure the host-side CAN application channel. See
“Configuring the Host Vector CAN Application Channel” on page 2-11.
2 Add a Switch External Mode Configuration Block (for ease of use; you can
also make changes manually).
2-9
2 Configuring Timing Parameters for CAN Blocks
4 Identify signals you want to log, and associate them with canlib.Signal
objects. It is important to set the data type of the canlib.Signal. See
“Using Supported Objects and Data Types” on page 2-12.
For information about visualizing logged signal data, see “Viewing and
Storing Signal Data” on page 2-14.
8 After downloading the executable to the target, you can switch the model to
external mode by double-clicking the Switch External Mode Configuration
Block. In the dialog box that appears, select External Mode, and click OK.
9 You can now connect to the target using external mode by clicking the
Connect button.
10 If you have set up tunable parameters, you can now tune them. See
“Tuning Parameters” on page 2-13.
If you do not want to use the Switch External Mode Configuration block, you
can configure for building and then external mode manually. For instructions,
see “Manual Configuration For External Mode” on page 2-17.
2-10
Parameter Tuning and Signal Logging
TargetsComms_VectorApplicationChannel.configureApplicationChannels
The Vector CAN Configuration tool appears. Use this tool to configure your
host-side CAN channel settings.
If you try to connect using an application channel other than 'MATLAB 1',
then you see the following warning in the command window:
Warning:
It was not possible to connect to the target using CCP.
An error occurred when issuing the CONNECT command.
If you have not already installed the Vector CAN drivers, you will get the
following error message:
If you want to use CAN to transmit or receive CAN messages between your
host PC and your target, you require Vector-Informatik CAN hardware
supported by the Vector CAN Driver Library. You must install the correct
driver libraries to support profiling, downloading, and external mode.
2-11
2 Configuring Timing Parameters for CAN Blocks
Note For CANcaseXL, you must install both the Vector XL-driver library
and Vector CAN Driver Library vcand32.dll.
For older CAN hardware, you must install the Vector CAN Driver Library
vcand32.dll.
Make sure that the library, vcand32.dll, is placed in the Windows® system32
folder.
• uint8, int8
• uint16, int16
• uint32, int32
• single
You need to define data objects for the signals and parameters of interest for
ASAP 2 file generation. For ease of use, create a MATLAB file to define the
data objects, so that you only have to set up the objects once.
stepSize = Simulink.Parameter;
2-12
Parameter Tuning and Signal Logging
stepSize.DataType = 'uint8';
stepSize.RTWInfo.StorageClass = 'ExportedGlobal';
stepSize.Value = 1;
counter = canlib.Signal;
counter.DataType = 'uint8';
3 Associate the data objects you defined in the MATLAB file with parameters
or signals in the model. For the previous code examples, you could set the
Constant value in a Source block to stepSize, and set a Signal name
to counter in the Signal Properties dialog box. Remember that stepSize
and counter are data objects defined in the code.
Tuning Parameters
To tune a parameter, follow these steps:
stepSize.value = 2
2-13
2 Configuring Timing Parameters for CAN Blocks
stepSize =
Simulink.Parameter (handle)
RTWInfo: [1x1 Simulink.ParamRTWInfo]
Description: ''
DataType: 'uint8'
Min: -Inf
Max: Inf
DocUnits: ''
Value: 2
Complexity: 'real'
Dimensions: [1 1]
2 Return to your model, and update the model (press Ctrl+D) to apply the
changed parameter.
Select which signals you want to log by using the External Signal &
Triggering dialog box. Access the External Mode Control Panel from the Tools
menu, and click the Signal & Triggering button. By default, all displays
appear as selected to be logged, as shown in the following example. Edit
these settings if you do not want to log all displays. Individual displays can
be selected manually.
2-14
Parameter Tuning and Signal Logging
Storing signal data for further analysis. It is possible to store the logged
data for further analysis in MATLAB.
1 To use the Data Archiving feature of external mode, click Data Archiving
in the External Mode Control Panel. The External Data Archiving dialog
box appears.
2-15
2 Configuring Timing Parameters for CAN Blocks
b Edit the Folder and Filename and any other desired settings.
2 Open the Scope parameters, and select the check box Save data to
workspace.
2-16
Parameter Tuning and Signal Logging
3 You may want to edit the Variable name in the edit box. The data that is
displayed on the scope at the end of the external mode session is available
in the workspace with this variable name.
The data that was previously displayed in the scope is stored in .mat files
as previously setup using Data Archiving.
For example, at the end of an external mode session, the following variable
and files could be available in the workspace and current folder:
• A variable ScopeData5 with the data currently displayed on the scope:
ScopeData5
ScopeData5 =
• In the current folder, .mat files for the three previous Durations of
scope data:
ExternalMode_0.mat
ExternalMode_2.mat
ExternalMode_1.mat
2 Select Normal simulation mode (in either the Simulation menu, or the
drop-down list in the toolbar).
2-17
2 Configuring Timing Parameters for CAN Blocks
After you build the model, you can configure it for external mode execution:
Limitations
Multiple signal sinks (e.g. scopes) are not supported.
Only the following kinds of scopes are supported with External Mode Logging:
Subsystem builds are not supported for external mode, only top-level builds
are supported.
2-18
Parameter Tuning and Signal Logging
Before you begin generating ASAP2 files with Target Support Package
software, you should read the “Generating an ASAP2 File” section of the
Real-Time Workshop documentation. That section describes how to define
the signal and parameter information required by the ASAP2 file generation
process.
3 Select the ASAP2 option from the Interface drop-down menu, in the Data
exchange frame.
2-19
2 Configuring Timing Parameters for CAN Blocks
4 Click Apply.
The build process creates an ASAM-compliant ASAP2 data definition file for
the generated C code.
2-20
3
Configuring Acquisition
Window Width for ADC
Blocks
3-2
What Is an Acquisition Window?
a circuit similar to the one shown in the following figure for the ADC found on
the F2812 eZdsp
Acquisition
Actual Signal Window
Width
3-3
3 Configuring Acquisition Window Width for ADC Blocks
3-4
Configuring ADC Parameters for Acquisition Window Width
3-5
3 Configuring Acquisition Window Width for ADC Blocks
These three prescalers serve to reduce the speed of the clock and to set the
acquisition window width. The following diagram shows how these prescalers
are used.
3-6
Configuring ADC Parameters for Acquisition Window Width
ADCLKPS CPS
1 - 16
(4 bit clock ACQ_PS
divider) CPS
ADCCLK -
HISPCLK this is the
(high speed CPS - ADC clock
peripheral further reduces signal
clock) ADCLKPS - the clock
reduces the frequency by a
incoming clock factor of 1 or 2 ACQ_PS -
frequency by a Acquisition
factor of 1 to 16 Prescaler -
indicates Sample
how many Hold
ADCCLK clock
ticks will pulse
comprise
the window
In the preceding diagram, the high speed peripheral clock frequency is
received and then divided by the ADCLKPS. The reduced clock frequency
is then further divided by CPS. The resulting frequency is the ADCCLK
signal. The value of ACQ_PS then determines how many ADCCLK ticks
comprise one S/H (sample and hold) period, or in other words, the length of
the acquisition window.
Examples
The following examples show how you can use ADC parameters to configure
the acquisition window width:
Example 1:
3-7
3 Configuring Acquisition Window Width for ADC Blocks
Example 2:
Note HISPCLK is set automatically for the user, and it is not possible to
change the rate. For more information, see “High-Speed Peripheral Clock”
on page 1-10
3-8
4
Introduction
The C28x IQmath Library blocks perform processor-optimized fixed-point
mathematical operations. These blocks correspond to functions in the Texas
Instruments C28x IQmath Library, an assembly-code library for the TI C28x
family of digital signal processors.
Note The implementation of this library for the TI C28x processor produces
the same simulation and code-generation output as the TI version of this
library, but it does not use a global Q value, as does the TI version. The Q
format is dynamically adjusted based on the Q format of the input data.
The IQmath Library blocks generally input and output fixed-point data types
and use numbers in Q format. The C28x IQmath Library block reference
pages discuss the data types accepted and produced by each block in the
library. For more information, consult the “Fixed-Point Numbers” on page
4-4 and “Q Format Notation” on page 4-5 topics, as well as the Simulink®
Fixed Point™ product documentation, which includes more information on
fixed-point data types, scaling, and precision issues.
You can use IQmath Library blocks with some core Simulink blocks and
Simulink Fixed Point blocks to run simulations in Simulink models before
generating code. Once you develop your model, you can invoke Real-Time
Workshop software to generate equivalent code that is optimized to run on a
TI C28x DSP. During code generation, a call is made to the IQmath Library
for each IQmath Library block in your model to create target-optimized code.
To learn more about creating models that include IQmath Library blocks and
blocks from other blocksets, consult “Building Models” on page 4-10.
4-2
About the IQmath Library
Common Characteristics
The following characteristics are common to all IQmath Library blocks:
References
For detailed information on the IQmath library, see the user’s guide for the
C28x IQmath Library - A Virtual Floating Point Engine, Literature Number
SPRC087, available at the Texas Instruments Web site. The user’s guide
is included in the zip file download that also contains the IQmath library
(registration required).
4-3
4 Using the IQmath Library
Fixed-Point Numbers
In this section...
“Notation” on page 4-4
“Signed Fixed-Point Numbers” on page 4-5
“Q Format Notation” on page 4-5
Notation
In digital hardware, numbers are stored in binary words. A binary word is a
fixed-length sequence of binary digits (1s and 0s). How hardware components
or software functions interpret this sequence of 1s and 0s is defined by the
data type.
where
4-4
Fixed-Point Numbers
Note For Target Support Package, the results of fixed-point and integer
operations in MATLAB/Simulink match the results on the hardware target
down to the least significant bit (bit-trueness). The results of floating-point
operations in MATLAB/Simulink do not match those on the hardware
target, because the libraries used by the third-party compiler may be
different from those used by MATLAB/Simulink.
• Sign/magnitude
• One’s complement
• Two’s complement
Q Format Notation
The position of the binary point in a fixed-point number determines how you
interpret the scaling of the number. When it performs basic arithmetic such
as addition or subtraction, hardware uses the same logic circuits regardless of
the value of the scale factor. In essence, the logic circuits have no knowledge of
a binary point. They perform signed or unsigned integer arithmetic — as if the
binary point is to the right of b0. Therefore, you determine the binary point.
4-5
4 Using the IQmath Library
In the IQmath Library, the position of the binary point in the signed,
fixed-point data types is expressed in and designated by Q format notation.
This fixed-point notation takes the form
Qm.n
where
In Q format, the most significant bit is always designated as the sign bit.
Representing a signed fixed-point data type in Q format always requires
m+n+1 bits to account for the sign.
Note The range and resolution varies for different Q formats. For specific
details, see Section 3.2 in the Texas Instruments C28x Foundation Software,
IQmath Library Module User’s Guide.
Example — Q.15
For example, a signed 16-bit number with n = 15 bits to the right of the
binary point is expressed as
4-6
Fixed-Point Numbers
Q0.15
Q.15
sfrac16
or
sfix16_En15
[16 15]
Example — Q1.30
Multiplying two Q0.15 numbers yields a product that is a signed 32-bit data
type with n = 30 bits to the right of the binary point. One bit is the designated
sign bit, thereby forcing m to be 1:
Q1.30
sfix32_En30
[32 30]
4-7
4 Using the IQmath Library
Example — Q-2.17
Consider a signed 16-bit number with a scaling of 2(-17). This requires n = 17
bits to the right of the binary point, meaning that the most significant bit
is a sign-extended bit.
Sign extension fills additional bits with the value of the MSB. For example,
consider a 4-bit two’s complement number 1011. When this number is
extended to 7 bits with sign extension, the number becomes 1111101 and the
value of the number remains the same.
Q-2.17
sfix16_En17
[16 17]
Example — Q17.-2
Consider a signed 16-bit number with a scaling of 2^(2) or 4. This means that
the binary point is implied to be 2 bits to the right of the 16 bits, or that there
are n = -2 bits to the right of the binary point. One bit must be the sign bit,
thereby forcing m to be 17:
m+n+1 = 17+(-2)+1 = 16
Q17.-2
sfix16_E2
4-8
Fixed-Point Numbers
[16 -2]
4-9
4 Using the IQmath Library
Building Models
In this section...
“Overview” on page 4-10
“Converting Data Types” on page 4-10
“Using Sources and Sinks” on page 4-11
“Choosing Blocks to Optimize Code” on page 4-11
“Double and Single-Precision Parameter Values” on page 4-11
Overview
You can use IQmath Library blocks in models along with certain core
Simulink, Simulink Fixed Point, and other blockset blocks. This section
discusses issues you should consider when building a model with blocks from
these different libraries.
When you connect IQmath Library blocks and Simulink Fixed Point blocks,
you often need to set the data type and scaling in the block parameters of the
Simulink Fixed Point block to match the data type of the IQmath Library
block. Many Simulink Fixed Point blocks allow you to set their data
type and scaling through inheritance from the driving block, or through
backpropagation from the next block. This can be a good way to set the data
type of a Simulink Fixed Point block to match a connected IQmath Library
block.
Some Signal Processing Blockset blocks and core Simulink blocks also accept
fixed-point data types. Make the appropriate settings in these blocks’
parameters when you connect them to an IQmath Library block.
4-10
Building Models
4-11
4 Using the IQmath Library
4-12
5
Programming Flash
Memory
Introduction
The Target Support Package software includes a feature for programming
Flash memory on the DSP target. You can configure this feature to
automatically program Flash memory when you build and execute models for
DSP boards. You can also use the Flash programming feature to selectively
erase, program, or verify specific sectors of Flash memory.
Requirements:
5-2
Installing TI Flash APIs
2 Start the TI Flash API installation software (.exe) contained in the ZIP file.
3 During installation, use the default folder location for Location to Save
Files.
Otherwise, each time you create a model, you must configure Specify API
Location, located under the Peripherals tab of the Target Preferences
block.
5-3
5 Programming Flash Memory
Typically, you can enable the bootloader switch or jumper by moving it from
the factory default position (Flash disabled) to the opposite position (enabled).
For example:
• On the F2812 eZdsp, change jumper JP7 from the factory default setting.
• On the F2808 eZdsp, change switches 1 and 3 on bank SW1 from the
factory default settings.
• On F28335 eZdsp, change switch 3 on bank SW1 from the factory default
setting.
5-4
Configuring the Software for Automatic Flash Programming
2 Open the Target Preferences block in your model, select the Peripherals
tab, and then select Flash_loader.
5-5
5 Programming Flash Memory
When you build the model, the software automatically erases, programs, and
verifies Flash memory. When the DSP board restarts, it loads and executes
the program from Flash memory.
5-6
Selectively Erase, Program, or Verify Specific Flash Sectors
1 Open the Target Preferences block in your model, and select the
Peripherals tab.
5 Click Execute. The software performs the action you specified upon the
unprotected flash sectors.
5-7
5 Programming Flash Memory
1 Determine the address and length of the individual Flash sectors. You may
need to refer to the manufacturer’s specifications.
2 Determine the size of the primary C code program and the number of Flash
sectors it occupies.
3 Determine the size of the additional code or data and the number of Flash
sectors it will occupy.
4 Under the Target Preferences Memory tab, click Add to create two or more
new memory banks; one for the primary C code program (e.g., FLASH_AB)
and one or more for the additional code or data (e.g., FLASH_CD). The
address and length of each memory bank must align with those of the flash
sectors.
5-8
Placing Additional Code or Data on Unused Flash Sectors
5 Under the Sections tab, under Default sections, select .text. Then, under
Placement, select the new memory bank (e.g., FLASH_AB) you created
for the primary C code program. The next time you program the Flash
memory, the software places the .text C code file in the new memory bank.
5-9
5 Programming Flash Memory
5-10
6
Configuring LIN
Communications
Overview
The LIN communications architecture supports a single master node and up
to 16 slave nodes on a LIN network.
LIN nodes use message frames to exchange data. The message has two parts:
6-2
Configuring Your Model
2 In the Target Preferences block, select the Peripherals tab, and then
select LIN.
• Add a LIN Transmit block to the model. This block enables the Master to
generate message headers.
• To send data, set the ID input and Tx ID Mask input to make Tx ID
Match happen on this node.
• To receive data, place LIN Receive block in the model. Set the Rx ID Mask
input to make Rx ID Match happen on this node.
For example, to configure a model with a master node that receives data
from a slave node:
• Add a LIN Transmit block and a LIN Receive block to the model.
• In the Target Preferences block, configure the ID Slave Task Byte.
• For the LIN Transmit block, set the ID input.
• For the LIN Receive block, set the Rx ID Mask input so that: Rx ID Mask
= ID XOR Slave Task ID Byte.
6-3
6 Configuring LIN Communications
• To send data, place LIN Transmit block in the model. Set the ID input
to match the LIN frame header issued by the remote Master. Set Tx ID
Mask to make a Tx ID Match happen on this node.
• To receive data, place LIN Receive block in the model. Set the Rx ID Mask
input to make an Rx ID Match happen on this node.
For example, to configure a model with a slave node that transmits data
to a master node:
Always set the Data type and Data length values in your LIN Receive blocks
to match the type and length of the transmitted data. These values enable the
receive block reconstruct the data from the message frames correctly.
Note The LIN Transmit block inherits the data type and length from its
input.
6-4
7
Block Reference
C280x (c280xlib)
C280x/C2802x/C2803x/C28x3x Receive and log capture input pin
eCAP transitions or configure auxiliary
pulse width modulator
C280x/C2802x/C2803x/C28x3x Configure Event Manager to
ePWM generate Enhanced Pulse Width
Modulator (ePWM) waveforms
C280x/C2802x/C2803x/C28x3x Configure general-purpose input
GPIO Digital Input pins
C280x/C2802x/C2803x/C28x3x Configure general-purpose
GPIO Digital Output input/output pins as digital
outputs
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Receive (I2C) module to receive data from
I2C bus
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Transmit (I2C) module to transmit data to I2C
bus
C280x/C2802x/C2803x/C28x3x SCI Receive data on target via serial
Receive communications interface (SCI) from
host
C280x/C2802x/C2803x/C28x3x SCI Transmit data from target via serial
Transmit communications interface (SCI) to
host
C280x/C2802x/C2803x/C28x3x Generate software triggered
Software Interrupt Trigger nonmaskable interrupt
C280x/C2802x/C2803x/C28x3x SPI Receive data via serial peripheral
Receive interface (SPI) on target
C280x/C2802x/C2803x/C28x3x SPI Transmit data via serial peripheral
Transmit interface (SPI) to host
C280x/C2803x/C28x3x eCAN Enhanced Control Area Network
Receive receive mailbox
7-2
C280x (c280xlib)
7-3
7 Block Reference
C2802x (c2802xlib)
C2802x/C2803x ADC Configure ADC to sample analog
pins and output digital data
C2802x/C2803x AnalogIO Input Configure pin, sample time, and
data type for analog input
C2802x/C2803x AnalogIO Output Configure Analog IO to output
analog signals on specific pins
C2802x/C2803x COMP Compare two input voltages on
comparator pins
C280x/C2802x/C2803x/C28x3x Receive and log capture input pin
eCAP transitions or configure auxiliary
pulse width modulator
C280x/C2802x/C2803x/C28x3x Configure Event Manager to
ePWM generate Enhanced Pulse Width
Modulator (ePWM) waveforms
C280x/C2802x/C2803x/C28x3x Configure general-purpose input
GPIO Digital Input pins
C280x/C2802x/C2803x/C28x3x Configure general-purpose
GPIO Digital Output input/output pins as digital
outputs
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Receive (I2C) module to receive data from
I2C bus
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Transmit (I2C) module to transmit data to I2C
bus
C280x/C2802x/C2803x/C28x3x SCI Receive data on target via serial
Receive communications interface (SCI) from
host
C280x/C2802x/C2803x/C28x3x SCI Transmit data from target via serial
Transmit communications interface (SCI) to
host
7-4
C2802x (c2802xlib)
7-5
7 Block Reference
C2803x (c2803xlib)
C2802x/C2803x ADC Configure ADC to sample analog
pins and output digital data
C2802x/C2803x AnalogIO Input Configure pin, sample time, and
data type for analog input
C2802x/C2803x AnalogIO Output Configure Analog IO to output
analog signals on specific pins
C2802x/C2803x COMP Compare two input voltages on
comparator pins
C2803x LIN Receive Receive data via local interconnect
network (LIN) module on target
C2803x LIN Transmit Transmit data from target via serial
communications interface (SCI) to
host
C280x/C2802x/C2803x/C28x3x Receive and log capture input pin
eCAP transitions or configure auxiliary
pulse width modulator
C280x/C2802x/C2803x/C28x3x Configure Event Manager to
ePWM generate Enhanced Pulse Width
Modulator (ePWM) waveforms
C280x/C2802x/C2803x/C28x3x Configure general-purpose input
GPIO Digital Input pins
C280x/C2802x/C2803x/C28x3x Configure general-purpose
GPIO Digital Output input/output pins as digital
outputs
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Receive (I2C) module to receive data from
I2C bus
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Transmit (I2C) module to transmit data to I2C
bus
7-6
C2803x (c2803xlib)
7-7
7 Block Reference
C281x (c281xlib)
C281x ADC Analog-to-digital converter (ADC)
C281x CAP Receive and log capture input pin
transitions
C281x eCAN Receive Enhanced Control Area Network
receive mailbox
C281x eCAN Transmit Enhanced Control Area Network
transmit mailbox
C281x GPIO Digital Input General-purpose I/O pins for digital
input
C281x GPIO Digital Output General-purpose I/O pins for digital
output
C281x PWM Pulse width modulators (PWMs)
C281x QEP Quadrature encoder pulse circuit
C281x SCI Receive Receive data on target via serial
communications interface (SCI) from
host
C281x SCI Transmit Transmit data from target via serial
communications interface (SCI) to
host
C281x Software Interrupt Trigger Generate software triggered
nonmaskable interrupt
C281x SPI Receive Receive data via serial peripheral
interface on target
C281x SPI Transmit Transmit data via serial peripheral
interface (SPI) to host
C281x Timer Configure general-purpose timer in
Event Manager module
7-8
C281x (c281xlib)
7-9
7 Block Reference
C28x3x (c2833xlib)
C280x/C2802x/C2803x/C28x3x Receive and log capture input pin
eCAP transitions or configure auxiliary
pulse width modulator
C280x/C2802x/C2803x/C28x3x Configure Event Manager to
ePWM generate Enhanced Pulse Width
Modulator (ePWM) waveforms
C280x/C2802x/C2803x/C28x3x Configure general-purpose input
GPIO Digital Input pins
C280x/C2802x/C2803x/C28x3x Configure general-purpose
GPIO Digital Output input/output pins as digital
outputs
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Receive (I2C) module to receive data from
I2C bus
C280x/C2802x/C2803x/C28x3x I2C Configure inter-integrated circuit
Transmit (I2C) module to transmit data to I2C
bus
C280x/C2802x/C2803x/C28x3x SCI Receive data on target via serial
Receive communications interface (SCI) from
host
C280x/C2802x/C2803x/C28x3x SCI Transmit data from target via serial
Transmit communications interface (SCI) to
host
C280x/C2802x/C2803x/C28x3x Generate software triggered
Software Interrupt Trigger nonmaskable interrupt
C280x/C2802x/C2803x/C28x3x SPI Receive data via serial peripheral
Receive interface (SPI) on target
C280x/C2802x/C2803x/C28x3x SPI Transmit data via serial peripheral
Transmit interface (SPI) to host
C280x/C2803x/C28x3x eCAN Enhanced Control Area Network
Receive receive mailbox
7-10
C28x3x (c2833xlib)
7-11
7 Block Reference
7-12
C28x IQmath (tiiqmathlib)
7-13
7 Block Reference
7-14
RTDX Instrumentation (rtdxBlocks)
7-15
7 Block Reference
7-16
8
Description This block computes the absolute value of an IQ number input. The
output is also an IQ number.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Arctangent IQN, Division IQN, Float to IQN, Fractional part IQN,
Fractional part IQN x int32, Integer part IQN, Integer part IQN x
int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x
IQN2, Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-2
Arctangent IQN
Description The Arctangent IQN block computes the four-quadrant arc tangent of
the IQ number inputs and produces IQ number output.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Function
Type of arc tangent to calculate:
• atan2 — Compute the four-quadrant arc tangent with output
in radians with values from -pi to +pi.
• atan2PU — Compute the four-quadrant arc tangent
per unit. If atan2(B,A) is greater than or equal to 0,
atan2PU(B,A) = atan2(B,A)/2*pi. Otherwise, atan2PU(B,A)
8-3
Arctangent IQN
Note The order of the inputs to the Arctangent IQN block correspond
to the Texas Instruments convention, with argument ’A’ at the top and
’B’ at bottom.
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Division IQN, Float to IQN, Fractional part IQN,
Fractional part IQN x int32, Integer part IQN, Integer part IQN x
int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x
IQN2, Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-4
C280x/C28x3x ADC
Library “C280x (c280xlib)” on page 7-2 and “C28x3x (c2833xlib)” on page 7-10
8-5
C280x/C28x3x ADC
Module
Specifies which DSP module to use:
• A — Displays the ADC channels in module A (ADCINA0
through ADCINA7).
• B — Displays the ADC channels in module B (ADCINB0
through ADCINB7).
• A and B — Displays the ADC channels in both modules A
and B (ADCINA0 through ADCINA7 and ADCINB0 through
ADCINB7).
8-6
C280x/C28x3x ADC
Conversion mode
Type of sampling to use for the signals:
• Sequential — Samples the selected channels sequentially.
• Simultaneous — Samples the corresponding channels of
modules A and B at the same time.
Start of conversion
Type of signal that triggers conversions to begin:
• Software — Signal from software. Conversion values are
updated at each sample time.
• ePWMxA / ePWMxB / ePWMxA_ePWMxB — Start of conversion is
controlled by user-defined PWM events.
• XINT2_ADCSOC — Start of conversion is controlled by the
XINT2_ADCSOC external signal pin.
Sample time
Time in seconds between consecutive sets of samples that are
converted for the selected ADC channel(s). This is the rate at
which values are read from the result registers. See “Scheduling
and Timing” on page 1-9 for more information on timing. To
execute this block asynchronously, set Sample Time to -1, check
the Post interrupt at the end of conversion box, and refer to
8-7
C280x/C28x3x ADC
8-8
C280x/C28x3x ADC
8-9
C280x/C28x3x ADC
8-10
C280x/C28x3x ADC
Number of conversions
Number of ADC channels to use for analog-to-digital conversions.
Conversion no.
Specific ADC channel to associate with each conversion number.
8-11
C280x/C28x3x ADC
block. If you use more than one channel and do not use multiple
output ports, the data is output in a single vector.
8-12
CAN Calibration Protocol
Note The CCP Data Acquisition (DAQ) List mode of operation is only
supported with Real-Time Workshop Embedded Coder. If Embedded
Coder is not available then custom storage classes canlib.signal are
ignored during code generation: this means that the CCP DAQ Lists
mode of operation cannot be used.
You can use the CCP Polling mode of operation with or without
Real-Time Workshop Embedded Coder.
The DAQ output is the output for any CCP Data Acquisition (DAQ) lists
that have been set up. You can use the ASAP2 file generation feature of
the Real-Time (RT) target to
8-13
CAN Calibration Protocol
Once these signals are set up, event channels then periodically fire
events that trigger the transmission of DAQ data to the host. When this
occurs, CAN messages with the appropriate CCP/DAQ data appear on
the DAQ output, along with an associated function call trigger.
The calibration tool (see “Compatibility with Calibration Packages” on
page 8-18) must use CCP commands to assign an event channel and
data to the available DAQ lists, and interpret the synchronous response.
Using DAQ lists for signal monitoring has the following advantages
over the polling method:
• There is no need for the host to poll for the data. Network traffic is
halved.
• The data is transmitted at the correct update rate for the signal.
Therefore, there is no unnecessary network traffic generated.
• Data is guaranteed to be consistent. The transmission takes
place after the signals have been updated, so there is no risk of
interruptions while sampling the signal.
8-14
CAN Calibration Protocol
Dialog
Box
8-15
CAN Calibration Protocol
A single ODT uses 56 bytes of memory. Using all 254 ODTs would
require over 14 KB of memory, a large proportion of the available
memory on the target. To conserve memory on the target, the
default number is low, allowing DAQ list signal monitoring with
reduced memory overhead and processing power.
8-16
CAN Calibration Protocol
ODTs are shared equally among DAQ lists and, therefore, you will
end up with one ODT per DAQ list. With less than three ODTs,
you get zero ODTs per DAQ list and the behavior is undefined.
Taking this example further, say you have three DAQ lists with
one ODT each, and start trying to monitor signals in a calibration
tool. If you try to assign too many signals to a particular DAQ list
(that is, signals requiring more space than seven bytes (one ODT)
in this case), then the calibration tool will report this as an error.
CRO sample time
The sample time for CRO messages.
• CONNECT
• DISCONNECT
• DNLOAD
• DNLOAD_6
• EXCHANGE_ID
• GET_CCP_VERSION
• GET_DAQ_SIZE
• GET_S_STATUS
• SET_DAQ_PTR
• SET_MTA
• SET_S_STATUS
• SHORT_UP
• START_STOP
• START_STOP_ALL
8-17
CAN Calibration Protocol
• TEST
• UPLOAD
• WRITE_DAQ
8-18
C280x/C2803x/C28x3x eCAN Receive
Library “C280x (c280xlib)” on page 7-2, “C2803x (c2803xlib)” on page 7-6, and
“C28x3x (c2833xlib)” on page 7-10
• The first output port is the function call port, and a function call
subsystem should be connected to this port. When a new message is
received, this subsystem is executed.
• The second output port is the message data port. The received data is
output in the form of a vector of elements of the selected data type.
The length of the vector is always 8 bytes. The message data port will
always output data. When the block is used in polling mode, if there
is no new message created between the consecutive executions of the
block, then the old message, or the existing message, is repeated.
• The third output port is optional and appears only if Output
message length is selected.
To use the eCAN Receive block with the eCAN Pack block in the
canmsglib, set Data type to CAN_MESSAGE_TYPE.
8-19
C280x/C2803x/C28x3x eCAN Receive
Dialog
Box
Chip family
Select the processor that has the eCAN module.
8-20
C280x/C2803x/C28x3x eCAN Receive
Module
Determines which of the two eCAN modules is being configured
by this instance of the eCAN Receive block. Options are eCAN_A
and eCAN_B.
This parameter is not visible when you set Chip family to C2803x.
Mailbox number
Sets the value of the mailbox number register (MBNR). For
standard CAN controller (SCC) mode, enter a unique number
from 0 to 15. For high-end CAN controller (HECC) mode enter a
unique number from 0 to 31 . In SCC mode, transmissions from
the mailbox with the highest number have the highest priority. In
HECC mode, the mailbox number only determines priority if the
Transmit priority level (TPL) of two mailboxes is equal.
Message identifier
Sets the value of the message identifier register (MID). The
message identifier is 11 bits long for standard frame size or 29 bits
long for extended frame size in decimal, binary, or hex format.
For the binary and hex formats, use bin2dec(' ') or hex2dec('
'), respectively, to convert the entry.
Message type
Select Standard (11-bit identifier) or Extended (29-bit
identifier).
Sample time
Frequency with which the mailbox is polled to determine if
a new message has been received. A new message causes a
function call to be emitted from the mailbox. If you want to
update the message output only when a new message arrives,
then the block needs to be executed asynchronously. To execute
this block asynchronously, set Sample Time to -1, check the
Post interrupt when message is received box, and refer to
“Asynchronous Interrupt Processing” on page 1-10 for a discussion
of block placement and other necessary settings.
8-21
C280x/C2803x/C28x3x eCAN Receive
Data type
Select one of the following options:
• uint8 (vector length = 8 elements)
• uint16 (vector length = 4 elements)
• uint32 (vector length = 2 elements)
• CAN_MESSAGE_TYPE (Select this option to use the eCAN receive
block with the CAN Unpack block.)
Output[0] = data_buffer[1..0];
Output[1] = data_buffer[3..2];
Output[2] = data_buffer[5..4];
Output[3] = data_buffer[7..6];
Output[0] = data_buffer[3..0];
Output[1] = data_buffer[7..4];
data_buffer[0] = 0x21
data_buffer[1] = 0x43
8-22
C280x/C2803x/C28x3x eCAN Receive
Output[0] = 0x4321
Output[1] = 0x0000
Output[2] = 0x0000
Output[3] = 0x0000
struct {
/* Is Extended frame */
uint8_T Extended;
/* Length */
uint8_T Length;
/* RTR */
uint8_T Remote;
/* Error */
uint8_T Error;
/* CAN ID */
uint32_T ID;
/*
TIMESTAMP_NOT_REQUIRED is a macro that will be defined by Target teams
PIL, C166, FM5, xPC if they do not require the timestamp field during code
generation. By default, timestamp is defined. If the targets do not require
the timestamp field, they should define the macro TIMESTAMP_NOT_REQUIRED before
including this header file for code generation.
*/
#ifndef TIMESTAMP_NOT_REQUIRED
/* Timestamp */
double Timestamp;
8-23
C280x/C2803x/C28x3x eCAN Receive
#endif
/* Data field */
uint8_T Data[8];
};
Initial output
Set the value the eCAN node outputs to the model before it has
received any data. The default value is 0.
Output message length
Select to output the message length in bytes to the third output
port. If not selected, the block has only two output ports.
Post interrupt when message is received
Select this check box to post an asynchronous interrupt when a
message is received.
Interrupt line
Select this check box to post an asynchronous interrupt when a
message is received.
References For detailed information on the eCAN module, see TMS320x281x, 280x
Enhanced Controller Area Network (eCAN) Reference Guide (Rev. D),
Literature Number SPRU074D, available at the Texas Instruments
Web site.
8-24
C280x/C2803x/C28x3x eCAN Transmit
Library “C280x (c280xlib)” on page 7-2, “C2803x (c2803xlib)” on page 7-6, and
“C28x3x (c2833xlib)” on page 7-10
Data Vectors
The length of the vector for each transmitted mailbox message is 8
bytes. Input data are always right-aligned in the message data buffer.
Only uint16 (vector length = 4 elements) or uint32 (vector length = 2
elements) data are accepted. The following examples show how the
different types of input data are aligned in the data buffer:
For input of type uint32,
8-25
C280x/C2803x/C28x3x eCAN Transmit
8-26
C280x/C2803x/C28x3x eCAN Transmit
Dialog
Box
Module
Determines which of the two eCAN modules is being configured
by this instance of the eCAN Transmit block. Options are eCAN_A
and eCAN_B.
Mailbox number
Unique number from 0 to 15 for standard or from 0 to 31 for
enhanced CAN mode. It refers to a mailbox area in RAM. In
standard mode, the mailbox number determines priority.
Message identifier
Identifier of length 11 bits for standard frame size or length 29
bits for extended frame size in decimal, binary, or hex. If in binary
or hex, use bin2dec(' ') or hex2dec(' '), respectively, to
convert the entry. The message identifier is coded into a message
that is sent to the CAN bus.
8-27
C280x/C2803x/C28x3x eCAN Transmit
Message type
Select Standard (11-bit identifier) or Extended (29-bit
identifier).
Enable blocking mode
If selected, the CAN block code waits indefinitely for a transmit
(XMT) acknowledge. If not selected, the CAN block code does not
wait for a transmit (XMT) acknowledge, which is useful when the
hardware might fail to acknowledge transmissions.
Post interrupt when message is transmitted
If selected, an asynchronous interrupt will be posted when data
is transmitted.
Note For information about setting the timing parameters of the CAN
module, see “Configuring Timing Parameters for CAN Blocks”.
References For detailed information on the eCAN module, see TMS320x281x, 280x
Enhanced Controller Area Network (eCAN) Reference Guide (Rev. D),
Literature Number SPRU074D, available at the Texas Instruments
Web site.
8-28
C280x/C2802x/C2803x/C28x3x eCAP
Purpose Receive and log capture input pin transitions or configure auxiliary
pulse width modulator
Library “C280x (c280xlib)” on page 7-2, “C2802x (c2802xlib)” on page 7-4, and
“C28x3x (c2833xlib)” on page 7-10
Description
Dialog The eCAP block dialog box provides configuration parameters on four
Box tabbed panes:
• General—Set the operating mode for the block (whether the block
performs eCAP or APWM processes, assign the pin associated, and
set the sample time
• eCAP—Configure eCAP functions such as prescaler value, capture
pin, and mode control
• APWM—Configure waveform and duty cycle values for the pulse
width modulation capability
• Interrupt—Specify when the block posts interrupts
You can add up to six eCAP blocks to your model, one block for each
capture pin. For example, you can have one block configured for eCAP
mode with eCAP1 pin selected and five blocks configured for APWM
mode with assigned pins eCAP2 through eCAP6. Or six blocks configured
for eCAP mode with each block assigned a different eCAP pin. You
cannot assign the same eCAP pin to two eCAP blocks in one model.
8-29
C280x/C2802x/C2803x/C28x3x eCAP
8-30
C280x/C2802x/C2803x/C28x3x eCAP
General Pane
Operating mode
When you select eCAP, the block captures and logs pin transitions
for each capture unit to a FIFO buffer. When you select APWM,
the block generates asymmetric pulse width modulation (APWM)
waveforms for driving downstream systems.
eCAPx pin
The capture unit includes the following features:
• One pin for each capture unit. For example, eCAP1, eCAP2,
and so on.
• Four maskable interrupt flags, one for each capture unit.
8-31
C280x/C2802x/C2803x/C28x3x eCAP
eCAP Pane
To enable the configuration parameters on this pane, select eCAP from
the Operating mode list on the General pane.
8-32
C280x/C2802x/C2803x/C28x3x eCAP
8-33
C280x/C2802x/C2803x/C28x3x eCAP
8-34
C280x/C2802x/C2803x/C28x3x eCAP
APWM Pane
To enable the configuration parameters on this pane, select APWM from
the Operating mode list on the General pane.
8-35
C280x/C2802x/C2803x/C28x3x eCAP
8-36
C280x/C2802x/C2803x/C28x3x eCAP
Waveform period
Period of the PWM waveform measured in clock cycles or in
seconds, as specified in the Waveform period units.
Interrupt Pane
In the following figure, you see the interrupt options when you put
the block in eCAP mode by setting Operating mode on the General
pane to eCAP.
8-37
C280x/C2802x/C2803x/C28x3x eCAP
The next figure presents the interrupt options when you put the block in
APWM mode by setting Operating mode on the General pane to APWM.
8-38
C280x/C2802x/C2803x/C28x3x eCAP
8-39
C280x/C2802x/C2803x/C28x3x ePWM
Library “C280x (c280xlib)” on page 7-2 and “C2802x (c2802xlib)” on page 7-4
and “C2803x (c2803xlib)” on page 7-6“C28x3x (c2833xlib)” on page 7-10
8-40
C280x/C2802x/C2803x/C28x3x ePWM
8-41
C280x/C2802x/C2803x/C28x3x ePWM
8-42
C280x/C2802x/C2803x/C28x3x ePWM
8-43
C280x/C2802x/C2803x/C28x3x ePWM
Counting mode
Specify the counting mode in which to operate. This PWM module
can operate in three distinct counting modes: Up, Down, and
Up-Down. The Down option is not compatible with HRPWM. To
avoid generating an error, do not select Down when you enable
HRPWM (Period).
8-44
C280x/C2802x/C2803x/C28x3x ePWM
8-45
C280x/C2802x/C2803x/C28x3x ePWM
8-46
C280x/C2802x/C2803x/C28x3x ePWM
8-47
C280x/C2802x/C2803x/C28x3x ePWM
Swap the ePWMA and ePWMB outputs. This option outputs the
ePWMA signals on the ePWMB outputs and the ePWMB signals
on the ePWMA outputs.
Enable HRPWM (Period)
This parameter only appears in the C2802x and C2803x ePWM
blocks.
8-48
C280x/C2802x/C2803x/C28x3x ePWM
8-49
C280x/C2802x/C2803x/C28x3x ePWM
8-50
C280x/C2802x/C2803x/C28x3x ePWM
8-51
C280x/C2802x/C2803x/C28x3x ePWM
8-52
C280x/C2802x/C2803x/C28x3x ePWM
Enable ePWMxA
Enable ePWMxB
Enables the ePWMA and/or ePWMB output signals for the ePWM
module identified on the General pane. By default, Enable
ePWMxA is enabled, and Enable ePWMxB is disabled.
8-53
C280x/C2802x/C2803x/C28x3x ePWM
CMPA units
CMPB units
Specify the units used by the compare register: Percentages (the
default) or Clock cycles.
Notes
• The term clock cycles refers to the Time-base Clock on the DSP.
See the TB clock prescaler divider topic for an explanation
of Time-base Clock speed calculations.
• Percentages use additional computation time in generated code
and can decrease performance.
• If you set CMPA units or CMPB units to Percentages, also
enable support for floating-point numbers: In the model
window, select Simulation > Configuration Parameters. In
the Configuration Parameters dialog box, select Real-Time
Workshop > Interface. Under Software Environment,
enable floating-point numbers.
8-54
C280x/C2802x/C2803x/C28x3x ePWM
port, WA or WB, on the block. If you select Input port also set
CMPA initial value or CMPB initial value.
CMPA value
CMPB value
This field appears when you choose Specify via dialog in
CMPA source or CMPB source. Enter a value that specifies
the pulse width, in the units specified in CMPA units or CMPB
units.
CMPA initial value
CMPB initial value
This field appears when you set CMPA source or CMPB source
to Input port. Enter the initial pulse width of CMPA or CMPB
the PWM peripheral uses when it starts operation. Subsequent
inputs to the WA or WB ports change the CMPA or CMPB pulse
width.
Action when counter=ZERO
Action when counter=PRD
Action when counter=CMPA on CAU
Action when counter=CMPA on CAD
Action when counter=CMPB on CBU
Action when counter=CMPB on CBD
These settings, along with the other remaining settings in the
ePWMA output and ePWMB output panes, determine the
behavior of the Action Qualifier (AQ) submodule. The AQ module
determines which events are converted into various action types,
producing the required switched waveforms of the ePWMxA and
ePWMxB output signals.
For each of these four fields, the available choices are Do nothing,
Clear, Set, and Toggle.
The default values for these fields vary between the ePWMA
output and ePWMB output panes.
8-55
C280x/C2802x/C2803x/C28x3x ePWM
The following table shows the defaults for each of these panes
when you set Counting mode to Up or Up-Down:
The following table shows the defaults for each of these panes
when you set Counting mode to Down:
8-56
C280x/C2802x/C2803x/C28x3x ePWM
If you did not create the SFA input port, you can use Continuous
S/W force logic to select which type of software force logic to
apply. The choices are:
• Forcing Disable: Do nothing. The default.
• Forcing Low: Clear low
• Forcing High: Set high
8-57
C280x/C2802x/C2803x/C28x3x ePWM
8-58
C280x/C2802x/C2803x/C28x3x ePWM
Swap the ePWMA and ePWMB outputs. This parameter sets the
SWAPAB field in the HRPWM Configuration Register (HRCNFG).
8-59
C280x/C2802x/C2803x/C28x3x ePWM
8-60
C280x/C2802x/C2803x/C28x3x ePWM
8-61
C280x/C2802x/C2803x/C28x3x ePWM
8-62
C280x/C2802x/C2803x/C28x3x ePWM
8-63
C280x/C2802x/C2803x/C28x3x ePWM
8-64
C280x/C2802x/C2803x/C28x3x ePWM
8-65
C280x/C2802x/C2803x/C28x3x ePWM
8-66
C280x/C2802x/C2803x/C28x3x ePWM
8-67
C280x/C2802x/C2803x/C28x3x ePWM
8-68
C280x/C2802x/C2803x/C28x3x ePWM
The software uses the higher 8 bits for the One shot TZ1-TZ6
and the lower 8 bits for Cyclic TZ1-TZ6. You can set up a group
of TZ sources (1~6), use a bit operation to combine them into an
integer, and then feed the integer to TZSEL.
For example, to enable One Shot TZ6 (OSHT6) and One Shot TZ5
(OSHT5) as trip zone sources, set OSHT6 and OSHT5 to “1” and
leave the remaining values as “0”.
8-69
C280x/C2802x/C2803x/C28x3x ePWM
Digital Compare
Use the Digital Compare pane to configure the Digital Compare (DC)
submodule.
Each digital compare (DC) submodule receives three TZ signals (TZ1 to
TZ3) from the GPIO MUX, and three COMP signals from the COMP.
These signals indicate fault or trip conditions that are external to the
8-70
C280x/C2802x/C2803x/C28x3x ePWM
DCAH, DCBH
If the TZ or COMP event you select occurs, assert a high signal.
Qualify this signal using the Generate DCAEVT#, Generate
DCBEVT# options.
DCAL, DCBL
If the TZ or COMP event you select occurs, assert a low signal.
Qualify this signal using the Generate DCAEVT#, Generate
DCBEVT# options.
8-71
C280x/C2802x/C2803x/C28x3x ePWM
Filtering
• Options that begin with DCAEVT# or DCAEVT# do not apply
filtering to DC events. Qualified signals trigger DC events.
• Options that begin with DCEVTFILT apply filtering to DC
events. Qualified signals pass through filtering circuits before
triggering DC events. This filtering is not configurable in
the ePWM block. For more information, refer to the “Event
Filtering” section of the TMS320x2802x, 2803x Piccolo
Enhanced Pulse Width Modulator (ePWM) Module Reference
Guide, Literature Number: SPRUGE9.
Synchronizing
• Options that end with async trigger DC events asynchronously.
When the qualified or filtered signals exist, the DC submodule
triggers the DC event immediately.
• Options that end with sync trigger DC events synchronously.
Once the qualified or filtered signals exist, the DC submodule
triggers the DC event in sync with the TBCLK signal.
8-72
C280x/C2802x/C2803x/C28x3x ePWM
8-73
C280x/C2803x/C28x3x eQEP
Description The enhanced quadrature encoder pulse (eQEP) module is used for
direct interface with a linear or rotary incremental encoder to get
position, direction, and speed information from a rotating machine for
use in a high-performance motion and position-control system.
8-74
C280x/C2803x/C28x3x eQEP
Module
If more than one eQEP module is available on your processor,
select the module this block configures.
Position counter mode
The input signals QEPA and QEPB are processed by the
Quadrature Decoder Unit (QDU) to produce clock (QCLK) and
direction (QDIR) signals. Choose the position counter mode
appropriate to the way the input to the eQEP module is encoded.
8-75
C280x/C2803x/C28x3x eQEP
8-76
C280x/C2803x/C28x3x eQEP
Sample time
Enter the sample time in seconds.
Position Counter Pane
8-77
C280x/C2803x/C28x3x eQEP
8-78
C280x/C2803x/C28x3x eQEP
8-79
C280x/C2803x/C28x3x eQEP
8-80
C280x/C2803x/C28x3x eQEP
Check this check box to enable the edge capture unit. This check
box is cleared by default.
Output capture timer
Select this check box to output the capture timer into the capture
period register. This check box is cleared by default.
Output capture period timer
Select this check box to output the capture period into the capture
period register. This check box is cleared by default.
eQEP capture timer prescaler
The eQEP capture timer runs from prescaled SYSCLKOUT. The
capture timer period is the value of SYSCLKOUT divided by
the value you choose in this field. Choices are 1, 2, 4, 8, 16, 32,
64, and 128 (the default).
Unit position event prescaler
The timing of the unit position event is determined by prescaling
the quadrature-clock (QCLK). QCLK is divided by the value you
choose in this popup. Choices are 4, 8, 16, 32, 64, 128, 256, 512,
1024, and 2048 (the default).
Enable and output overflow error flag
Select this check box to enable and output the eQEP overflow
error flag in the event of capture timer overflow between unit
position events.
Enable and output direction change error flag
Select this check box to enable and output the direction change
error flag.
Capture timer and position
Choose the event that triggers the latching of the capture timer
and capture period register: On position counter read (the
default) or On unit time-out event.
Unit timer period
This field appears only when you choose On unit time-out
event in Capture timer and position. Enter a value for the
8-81
C280x/C2803x/C28x3x eQEP
8-82
C280x/C2803x/C28x3x eQEP
8-83
C280x/C2803x/C28x3x eQEP
8-84
C280x/C2803x/C28x3x eQEP
8-85
C280x/C2803x/C28x3x eQEP
8-86
C280x/C2803x/C28x3x eQEP
The image above shows the default condition of the Signal data types
pane. Choosing any of a number of options in other panes of the eQEP
dialog box causes a corresponding popup to appear in the Signal data
types pane.
The following table summarizes the options for which you can set the
data type in the Signal data types pane:
8-87
C280x/C2803x/C28x3x eQEP
Pane Option
General Quadrature phase error flag output port
Quadrature direction flag output port
Position Output position counter (selected by default)
counter
Output position counter error flag
Output latch position counter on index event
Output latch position counter on strobe event
Speed Output capture timer
calculation
Output capture period timer
Enable and output overflow error flag
Enable and output direction change error flag
Output capture timer latched value
Output capture timer period latched value
Output position counter latched value
Watchdog unit Enable watchdog time out flag via output port
The fields that appear on the Signal data types pane are named
similarly to these options. For example, Position counter value
data type on the Signal data types pane corresponds to the Output
position counter option on the Position counter pane.
For all data type fields, valid data types are auto, double, single,
int8, uint8, int16, uint16, int32, uint32, and boolean.
8-88
C280x/C2803x/C28x3x eQEP
Interrupt Pane
The image above shows the default condition of the Interrupt pane.
Interrupts corresponding to specific events are enabled or disabled
based on the settings in this pane.
8-89
C280x/C2803x/C28x3x eQEP
8-90
C280x/C2803x/C28x3x eQEP
References For more information on the QEP module, consult the following
documents, available at the Texas Instruments Web site:
8-91
C280x/C2802x/C2803x/C28x3x GPIO Digital Input
Description
Note To avoid losing any new settings, click Apply before changing the
GPIO Group parameter.
8-92
C280x/C2802x/C2803x/C28x3x GPIO Digital Input
Dialog
Box
The dialog boxes for the C2802x and C28x3x processors are similar to
that of the C280x, shown in the preceding figure.
GPIO Group
Select the group of GPIO pins you want to view or configure.
For a table of GPIO pins and peripherals, refer to the Texas
Instruments documentation for your specific target.
Sample time
Specify the time interval between output samples. To inherit
sample time from the upstream block, set this parameter to -1.
8-93
C280x/C2802x/C2803x/C28x3x GPIO Digital Input
8-94
C280x/C2802x/C2803x/C28x3x GPIO Digital Output
Note To avoid losing any new settings, click Apply before changing the
GPIO Group parameter.
8-95
C280x/C2802x/C2803x/C28x3x GPIO Digital Output
Dialog
Box
The dialog boxes for the C2802x and C28x3x processors are similar to
that of the C280x, shown in the preceding figure.
GPIO Group
Select the group of GPIO pins you want to view or configure.
GPIO pins for output
To configure a GPIO pin for digital output, select the checkbox
next to it. Refer to the block for a table of all available peripherals
for each pin.
A value of True at the input of the block drives the selected GPIO
pin high. A value of False at the input of the block grounds the
selected GPIO pin.
Toggle GPIO[bit#]
For each pin selected for output, you can elect to toggle the signal
of that pin. In Toggle mode, a value of True at the input of the
8-96
C280x/C2802x/C2803x/C28x3x GPIO Digital Output
block switches the GPIO pin output level. Thus, if the GPIO pin
was driven high, in Toggle mode, with the value of True at the
input, the pin output level is driven low. If the GPIO pin was
driven low, in Toggle mode, with the value of True at the input of
the block, the same pin output level is driven high. If the input of
the block is False, there is no effect on the GPIO pin output level.
8-97
C280x/C2802x/C2803x/C28x3x I2C Receive
Description Configure the I2C module to receive data from the two-wire I2C serial
bus.
8-98
C280x/C2802x/C2803x/C28x3x I2C Receive
Dialog
Box
Addressing format
The I2C receive block supports the 7–Bit addressing, 10–Bit
addressing, and Free data format. The default setting is 7–Bit
addressing.
Slave address source
Select the method for setting the slave address register of the
I2C slave. Selecting Specify via dialog displays Slave address
8-99
C280x/C2802x/C2803x/C28x3x I2C Receive
8-100
C280x/C2802x/C2803x/C28x3x I2C Receive
8-101
C280x/C2802x/C2803x/C28x3x I2C Transmit
Description Configure the I2C module to transmit data to the two-wire I2C serial
bus.
Note You can use this block to configure the I2C settings under the
Peripherals tab of the target preference blocks for the F2808 eZdsp,
and F28335 eZdsp boards.
Dialog
Box
8-102
C280x/C2802x/C2803x/C28x3x I2C Transmit
Addressing format
The I2C transmit block supports the 7–Bit addressing, 10–Bit
addressing, and Free data format. The default setting is 7–Bit
addressing.
Slave address source
Select the method for setting the slave address register of the
I2C slave. Selecting Specify via dialog displays Slave address
register parameter . Selecting Input port enables definition
of the address register via the input port. The default setting
is Specify via dialog.
Slave address register
When you select Specify via dialog, enter a value for the Slave
address register. The default value is 80.
Bit Count
Set the bit count to 1 through 8. The default setting is 8.
Enable stop condition
Selecting this parameter enables the transmitter to accept a
STOP condition from the C280x/C2802x/C2803x/C28x3x I2C
Receive block. The default setting is disabled (not selected).
Enable repeat mode
When you enable repeat mode, the I2C module retransmits the
same data until it detects a stop or start condition. If you use this
mode, also consider selecting Enable stop condition.
8-103
C280x/C2802x/C2803x/C28x3x I2C Transmit
8-104
C280x/C2802x/C2803x/C28x3x SCI Receive
Purpose Receive data on target via serial communications interface (SCI) from
host
Note For any given model, you can have only one SCI Receive block
per module. There are two modules, A and B, which can be configured
through the Target Preferences block.
8-105
C280x/C2802x/C2803x/C28x3x SCI Receive
Dialog
Box
SCI module
SCI module to be used for communications.
8-106
C280x/C2802x/C2803x/C28x3x SCI Receive
8-107
C280x/C2802x/C2803x/C28x3x SCI Receive
Initial output
Default value from the SCI Receive block. This value is used,
for example, if a connection time-out occurs and the Action
taken when connection timeout field is set to “Output the last
received value”, but nothing yet has been received.
Action taken when connection timeout
Specify what to output if a connection time-out occurs. If “Output
the last received value” is selected, the last received value is what
is output, unless none has been received yet, in which case the
Initial output is considered the last received value.
If you select "Output custom value", use the "Output value when
connection times out" field to set the custom value.
8-108
C280x/C2802x/C2803x/C28x3x SCI Receive
8-109
C280x/C2802x/C2803x/C28x3x SCI Receive
Sample time
Sample time, Ts, for the block’s input sampling. To execute this
block asynchronously, set Sample Time to -1, and refer to
“Asynchronous Interrupt Processing” on page 1-10 for a discussion
of block placement and other necessary settings.
Output receiving status
When this field is checked, the SCI Receive block adds another
output port for the transaction status, and appears as shown in
the following figure.
8-110
C280x/C2802x/C2803x/C28x3x SCI Receive
References For detailed information on the SCI module, see TMS320x281x, 280x
DSP Serial Communication Interface (SCI) Reference Guide, Literature
Number SPRU051B, available at the Texas Instruments Web site.
8-111
C280x/C2802x/C2803x/C28x3x SCI Transmit
Purpose Transmit data from target via serial communications interface (SCI)
to host
Description The SCI Transmit block transmits scalar or vector data in int8 or
uint8 format from the target’s COM ports in nonreturn-to-zero (NRZ)
format. You can specify how many of the six target COM ports to use.
The sampling rate and data type are inherited from the input port.
The data type of the input port must be one of the following: single,
int8, uint8, int16, uint16, int32, uint32. If no data type is specified, the
default data type is uint8.
Note For any given model, you can have only one SCI Transmit block
per module. There are two modules, A and B, which can be configured
through the Target Preferences block.
8-112
C280x/C2802x/C2803x/C28x3x SCI Transmit
Dialog
Box
SCI module
SCI module to be used for communications.
Additional package header
This field specifies the data located at the front of the sent data
package, which is not part of the data being transmitted, and
generally indicates start of data. The additional package header
must be an ASCII value. You may use any string or number
(0–255). You must put single quotes around strings entered in
this field, but the quotes are not sent nor are they included in
the total byte count. To specify a null value (no package header),
enter two single quotes alone.
8-113
C280x/C2802x/C2803x/C28x3x SCI Transmit
References For detailed information on the SCI module, see TMS320x281x, 280x
DSP Serial Communication Interface (SCI) Reference Guide, Literature
Number SPRU051B, available at the Texas Instruments Web site.
8-114
C280x/C2802x/C2803x/C28x3x Software Interrupt
Trigger
Description When you add this block to a model, the block polls the input port for
the input value. When the input value is greater than the value in
Trigger software interrupt when input value is greater than, the
block posts the interrupt to a Hardware Interrupt block in the model.
To use this block, add a Hardware Interrupt block to your model
to process the software triggered interrupt from this block into an
interrupt service routine on the processor. Set the interrupt number
in the Hardware Interrupt block to the value you set here in CPU
interrupt number.
The CPU and PIE interrupt numbers together specify a single interrupt
for a single peripheral or peripheral module. The following table maps
CPU and PIE interrupt numbers to these peripheral interrupts. The
row numbers are CPU values and the column numbers are the PIE
values.
8-115
C280x/C2802x/C2803x/C28x3x Software Interrupt
Trigger
Dialog
Box
8-116
C280x/C2802x/C2803x/C28x3x Software Interrupt
Trigger
8-117
C280x/C2802x/C2803x/C28x3x SPI Receive
8-118
C280x/C2802x/C2803x/C28x3x SPI Receive
Dialog
Box
Select module
Select the SPI module to be used for communications. Each
processor has a different number of modules.
Data length
Specify how many uint16s are expected to be received. Select
1 through 16.
Initial output
Set the value the SPI node outputs to the model before it has
received any data.
8-119
C280x/C2802x/C2803x/C28x3x SPI Receive
8-120
C280x/C2802x/C2803x/C28x3x SPI Transmit
Note For any given model, you can have only one SPI Transmit block
per module. There are two modules, A and B, which can be configured
through the Target Preferences block.
8-121
C280x/C2802x/C2803x/C28x3x SPI Transmit
Dialog
Box
Select module
Select the SPI module to be used for communications. Each
processor has a different number of modules.
Output transmit error status
When this field is checked, the SPI Transmit block adds another
output port for the transaction status, and appears as shown in
the following figure.
8-122
C280x/C2802x/C2803x/C28x3x SPI Transmit
8-123
C2802x/C2803x COMP
Library “C2802x (c2802xlib)” on page 7-4 and “C2803x (c2803xlib)” on page 7-6
Description Configures the COMP to output a constant data from the comparator
pins on the DSP.
Dialog
Box
Comparator module
Select which comparator module the block configures. Use only
one block per module.
Comparator # output pin
Select the GPIO pin to use for the comparator output.
8-124
C2802x/C2803x COMP
Comparator source
Select Two external analog inputs to compare the voltage of
Input Pin A with Input Pin B. Select One external analog
inputs to compare the voltage of Input Pin A with the output of
a DAC reference located in the comparator. For more information,
see the “DAC Reference” section of the TMS320x2802x, 2803x
Piccolo Analog-to-Digital Converter (ADC) and Comparator.
8-125
C2802x/C2803x ADC
Purpose Configure ADC to sample analog pins and output digital data
Library “C2802x (c2802xlib)” on page 7-4 and “C2803x (c2803xlib)” on page 7-6
Description Configures the ADC to output a constant stream of data collected from
the ADC pins on the DSP.
8-126
C2802x/C2803x ADC
Dialog
Box
Sampling mode
Select Single sample mode to sample two signals sequentially.
Select Simultaneous sample mode to sample the two signals
with a minimal delay between the samples.
SOC trigger number
Identify the start-of-conversion trigger by number. In single
sampling mode, you can select an individual trigger. In
simultaneous sampling mode, you can select triggers in pairs.
8-127
C2802x/C2803x ADC
8-128
C2802x/C2803x ADC
Interrupt selection
Select which interrupt the ADC posts after triggering an EOC
pulse.
ADCINT1 continuous mode
ADCINT2 continuous mode
When the ADC generates an end of conversion (EOC) signal,
generate an ADCINT# interrupt whether the previous interrupt
flag has been acknowledged or not.
Input Channels — Conversion channel
Select the input channel to which this ADC conversion applies.
8-129
C2802x/C2803x ADC
8-130
C2802x/C2803x ADC
“ADC”
8-131
C2802x/C2803x AnalogIO Input
Purpose Configure pin, sample time, and data type for analog input
Library “C2802x (c2802xlib)” on page 7-4 and “C2803x (c2803xlib)” on page 7-6
Description Use this block to sample the Analog IO input pins on the C2802x
processor for a positive voltage and output the results.
Dialog
Box
8-132
C2802x/C2803x AnalogIO Input
Sample time
Specify the time interval between samples. To inherit sample
time from the upstream block, set this parameter to -1.
Data type
Select the data type of the digital output data. If you select auto,
the block automatically selects the correct data type for your
model. You can also manually select a data type. You can choose
from the options double, single, int8, uint8, int16, uint16,
int32, and uint32.
8-133
C2802x/C2803x AnalogIO Output
Library “C2802x (c2802xlib)” on page 7-4 and “C2803x (c2803xlib)” on page 7-6
Description Configures the Analog IO output pins for the specified pins. In regular
mode, a value of True at the input of the block pulls the Analog IO
pin high. A value of False grounds the pin. In toggle mode, a value of
True at the input of the block switches the actual output level of the
Analog IO pin. A value of False does not affect on the output level of
the Analog IO pin.
Dialog
Box
8-134
C2802x/C2803x AnalogIO Output
8-135
C2803x LIN Receive
Purpose Receive data via local interconnect network (LIN) module on target
• ID: Set the value of the LIN ID for the LIN transmit node.
• Tx ID Mask: Set the value of the LIN ID mask for the LIN transmit
node.
• Data: Connect this input to the data source.
8-136
C2803x LIN Receive
Dialog
Box
Data type
Select the data type the LIN block outputs to the model. Available
options are single, int8, uint8, int16, uint16, int32, or uint32.
To interpret the data correctly, the data type and data length
must match those of the data input to transmitting LIN node.
8-137
C2803x LIN Receive
Data length
Set the length of the data the LIN block outputs to the model. This
value is measured in multiples of the Data type. For example,
if Data type is int16 and Data length is int16, the LIN block
outputs the data to the model in lengths of
1 x int16
If you set the Data length to a value greater than 1, the block
outputs the data as vectors.
To interpret the data correctly, the data type and data length
must match those of the data input to transmitting LIN node.
Initial output
Set the initial value the DATA port outputs to the model before
the LIN node has received any data.
8-138
C2803x LIN Receive
If the LIN node has not received data, and you set this parameter
to Output the last received value, the DATA port outputs
the Initial output value.
Output value when connection times out
Specify the custom value the DATA port outputs when Action
taken when connection times out is set to Output custom
value and a connection timeout occurs.
Enable blocking mode
If you enable (select) this checkbox, the target application stops
and waits for the LIN node to receive data before continuing. If
you disable this option, the application continues running and
does not wait for data to arrive.
The status output reports the following values for each message
the LIN node receives:
• 0: No error.
• -1: A time-out occurred while the block was waiting to receive
data.
• -2: Unable to receive.
• Other status values represent the highest 8 bits of the SCI
Flags Register. Convert these values from decimal to binary.
8-139
C2803x LIN Receive
8-140
C2803x LIN Receive
If you enable this option, also enable Parity mode in the Target
Preferences block.
ID match interrupt
If you enable this option, the LIN module generates an interrupt
when the LIN node validates the ID in messages it receives.
8-141
C2803x LIN Transmit
Purpose Transmit data from target via serial communications interface (SCI)
to host
• ID: Set the value of the LIN ID for the LIN transmit node.
• Tx ID Mask: Set the value of the LIN ID mask for the LIN transmit
node.
• Data: Connect this input to the data source.
8-142
C2803x LIN Transmit
Dialog
Box
Send checksum
Select this checkbox to include a checksum in the last data field of
the checkbyte. LIN 2.0 implementations require this checksum.
The TXRX Error Detector Bit Monitor compares data bits on the
LIN transmit (LINTX) and receive (LINRX) pins. If the data
do not match, the Bit Monitor raises a bit-error flag. When you
8-143
C2803x LIN Transmit
8-144
C281x ADC
Description The C281x ADC block configures the C281x ADC to perform
analog-to-digital conversion of signals connected to the selected ADC
input pins. The ADC block outputs digital values representing the
analog input signal and stores the converted values in the result
register of your digital signal processor. You use this block to capture
and digitize analog signals from external sources such as signal
generators, frequency generators, or audio devices.
Triggering
The C281x ADC trigger mode depends on the internal setting of the
source start-of-conversion (SOC) signal. In unsynchronized mode the
ADC is usually triggered by software at the sample time intervals
specified in the ADC block. For more information on configuring the
specific parameters for this mode, see “Configuring Acquisition Window
Width for ADC Blocks”.
In synchronized mode, the Event (EV) Manager associated with the
same module as the ADC triggers the ADC. In this case, the ADC
is synchronized with the pulse width modulator (PWM) waveforms
generated by the same EV unit via the ADC Start Event signal
setting. The ADC Start Event is set in the C281x PWM block. See
that block for information on the settings.
Note The ADC cannot be synchronized with the PWM if the ADC is in
cascaded mode (see below).
Output
The output of the C281x ADC is a vector of uint16 values. The output
values are in the range 0 to 4095 because the C281x ADC is 12-bit
converter.
8-145
C281x ADC
Modes
The C281x ADC block supports ADC operation in dual and cascaded
modes. In dual mode, either module A or module B can be used for the
ADC block, and two ADC blocks are allowed in the model. In cascaded
mode, both module A and module B are used for a single ADC block.
Module
Specify which DSP module to use:
• A — Displays the ADC channels in module A (ADCINA0
through ADCINA7).
• B — Displays the ADC channels in module B (ADCINB0
through ADCINB7).
8-146
C281x ADC
Then, use the check boxes to select the desired ADC channels.
Conversion mode
Type of sampling to use for the signals:
• Sequential — Samples the selected channels sequentially
• Simultaneous — Samples the corresponding channels of
modules A and B at the same time
Start of conversion
Specify the type of signal that triggers the conversion:
• Software — Signal from software
• EVA — Signal from Event Manager A (only for Module A)
• EVB — Signal from Event Manager B (only for Module B)
• External — Signal from external hardware
Sample time
Time in seconds between consecutive sets of samples that are
converted for the selected ADC channel(s). This is the rate at
which values are read from the result registers. See “Scheduling
and Timing” on page 1-9 for more information on timing. To
execute this block asynchronously, set Sample Time to -1, check
the Post interrupt at the end of conversion box, and refer to
“Asynchronous Interrupt Processing” on page 1-10 for a discussion
of block placement and other necessary settings.
8-147
C281x ADC
Number of conversions
Number of ADC channels to use for analog-to-digital conversions.
Conversion no.
Specific ADC channel to associate with each conversion number.
8-148
C281x ADC
8-149
C281x CAP
Description The C281x CAP block sets parameters for the capture units (CAPs) of
the Event Manager (EV) module. The capture units log transitions
detected on the capture unit pins by recording the times of these
transitions into a two-level deep FIFO stack. You can set the capture
unit pins to detect rising edge, falling edge, either type of transition,
or no transition.
The C281x chip has six capture units — three associated with each
EV module. Capture units 1, 2, and 3 are associated with EVA and
capture units 4, 5, and 6 are associated with EVB. Each capture unit is
associated with a capture input pin.
Each group of EV module capture units can use one of two
general-purpose (GP) timers on the target board. EVA capture units
can use GP timer 1 or 2. EVB capture units can use GP timer 3 or 4.
When a transition occurs, the module stores the value of the selected
timer in the two-level deep FIFO stack.
The C281x CAP module shares GP Timers with other C281 blocks. For
more information and guidance on sharing timers, see “Sharing General
Purpose Timers between C281x Peripherals” on page 1-15.
Note You can have up to two C281x CAP blocks in any one model—one
block for each EV module.
Outputs
This block has up to two outputs: a cnt (count) output and an optional,
FIFO status flag output. The cnt output increments each time a
transition of the selected type occurs. The status flag outputs are
8-150
C281x CAP
8-151
C281x CAP
Module
Select the Event Manager (EV) module to use:
• A — Use CAPs 1, 2, and 3.
• B — Use CAPs 4, 5, and 6.
Output overrun status flag
Select to output the status of the elements in the FIFO. The data
type of the status flag is uint16.
Send data format
The type of data to output:
• Send 2 elements (FIFO Buffer) — Sends the latest two
values. The output is updated when there are two elements
in the FIFO, which is indicated by bit 13 or 11 or 9 being
sent (CAP x FIFO). If the CAP is polled when fewer than two
elements are captures, old values are repeated. The CAP
registers are read as follows:
1 The CAP x FIFO status bits are read and the value is stored
in the status flag.
2 The top value of the FIFO is read and stored in the output
at index 0.
3 The new top value of the FIFO (the previously stored bottom
stack value) is read and stored in the output at index 1.
• Send 1 element (oldest) — Sends the older of the two most
recent values. The output is updated when there is at least
one element in the FIFO, which is indicated by any of the bits
13:12, or 11:10, or 9:8 being sent. The CAP registers are read
as follows:
4 The CAP x FIFO status bits are read and the value is stored
in the status flag.
5 The top value of the FIFO is read and stored in the output.
• Send 1 element (latest) — Sends the most recent value.
The output is updated when there is at least one element in the
8-152
C281x CAP
8-153
C281x CAP
CAP Panes
The CAP panes set parameters for individual CAPs. The particular
CAP affected by a CAP pane depends on the EV module you selected:
Enable CAP
Select to use the specified capture unit pin.
8-154
C281x CAP
Edge Detection
Type of transition detection to use for this CAP. Available
types are Rising Edge, Falling Edge, Both Edges, and No
transition.
Time Base
Select which target board GP timer the CAP uses as a time base.
CAPs 1, 2, and 3 can use Timer 1 or Timer 2. CAPs 4, 5, and 6
can use Timer 3 or Timer 4.
Clock source
This option is available only for the CAP 3 pane. You can select
Internal to use the internal time base. Also configure the
Counting mode, Timer prescaler, and Timer period source
for the internal time base.
8-155
C281x CAP
8-156
C281x CAP
8-157
C281x CAP
If you know the length of a clock cycle, you can easily calculate
how many clock cycles to set for the timer period. The following
calculation determines the length of one clock cycle:
See Also
C281x Hardware Interrupt
8-158
C281x eCAN Receive
Description Use the C281x enhanced Control Area Network (eCAN) Receive block to
receive eCAN messages through an eCAN mailbox. The eCAN module
on the DSP chip provides serial communication capability and has 32
mailboxes configurable for receive or transmit. The C281x supports
eCAN data frames in standard or extended format.
The C281x eCAN Receive block has up to three output ports.
To use the eCAN Receive block with the eCAN Pack block in the
canmsglib, set Data type to CAN_MESSAGE_TYPE.
8-159
C281x eCAN Receive
Dialog
Box
Mailbox number
Unique number between 0 and 15 for standard or between 0 and
31 for enhanced CAN mode. It refers to a mailbox area in RAM.
In standard mode, the mailbox number determines priority.
Message identifier
Identifier of length 11 bits for standard frame size or length 29
bits for extended frame size in decimal, binary, or hex. If in
binary or hex, use bin2dec(' ') or hex2dec(' '), respectively,
to convert the entry. The message identifier is associated with a
8-160
C281x eCAN Receive
Data type
Select one of the following options:
• uint16 (vector length = 4 elements)
• uint32 (vector length = 2 elements)
• CAN_MESSAGE_TYPE (Select this option to use the eCAN receive
block with the CAN Unpack block.)
8-161
C281x eCAN Receive
Output[0] = data_buffer[1..0];
Output[1] = data_buffer[3..2];
Output[2] = data_buffer[5..4];
Output[3] = data_buffer[7..6];
Output[0] = data_buffer[3..0];
Output[1] = data_buffer[7..4];
data_buffer[0] = 0x21
data_buffer[1] = 0x43
Output[0] = 0x4321
Output[1] = 0x0000
Output[2] = 0x0000
Output[3] = 0x0000
struct {
/* Is Extended frame */
uint8_T Extended;
/* Length */
uint8_T Length;
/* RTR */
uint8_T Remote;
8-162
C281x eCAN Receive
/* Error */
uint8_T Error;
/* CAN ID */
uint32_T ID;
/*
TIMESTAMP_NOT_REQUIRED is a macro that will be defined by Target teams
PIL, C166, FM5, xPC if they do not require the timestamp field during code
generation. By default, timestamp is defined. If the targets do not require
the timestamp field, they should define the macro TIMESTAMP_NOT_REQUIRED before
including this header file for code generation.
*/
#ifndef TIMESTAMP_NOT_REQUIRED
/* Timestamp */
double Timestamp;
#endif
/* Data field */
uint8_T Data[8];
};
References For detailed information on the eCAN module, see TMS320F28x DSP
Enhanced Control Area Network (eCAN) Reference Guide, Literature
Number SPRU074A, available at the Texas Instruments Web site.
8-163
C281x eCAN Receive
8-164
C281x eCAN Transmit
Description The C281x enhanced Control Area Network (eCAN) Transmit block
generates source code for transmitting eCAN messages through an
eCAN mailbox. The eCAN module on the DSP chip provides serial
communication capability and has 32 mailboxes configurable for receive
or transmit. The C28x supports eCAN data frames in standard or
extended format.
Data Vectors
The length of the vector for each transmitted mailbox message is 8
bytes. Input data are always right-aligned in the message data buffer.
Only uint16 (vector length = 4 elements) or uint32 (vector length = 2
elements) data are accepted. The following examples show how the
different types of input data are aligned in the data buffer
For input of type uint32,
8-165
C281x eCAN Transmit
8-166
C281x eCAN Transmit
Dialog
Box
Mailbox number
Unique number between 0 and 15 for standard or between 0 and
31 for enhanced CAN mode. It refers to a mailbox area in RAM.
In standard mode, the mailbox number determines priority.
Message identifier
Identifier of length 11 bits for standard frame size or length 29
bits for extended frame size in decimal, binary, or hex. If in binary
or hex, use bin2dec(' ') or hex2dec(' '), respectively, to
convert the entry. The message identifier is coded into a message
that is sent to the CAN bus.
Message type
Select Standard (11-bit identifier) or Extended (29-bit
identifier).
8-167
C281x eCAN Transmit
Note For information about setting the timing parameters of the CAN
module, see “Configuring Timing Parameters for CAN Blocks”.
References For detailed information on the eCAN module, see TMS320F28x DSP
Enhanced Control Area Network (eCAN) Reference Guide, Literature
Number SPRU074A, available at the Texas Instruments Web site.
8-168
C281x GPIO Digital Input
Description This block configures the general-purpose I/O (GPIO) registers that
control the GPIO shared pins for digital input. Each I/O port has one
MUX register, which is used to select peripheral operation or digital
I/O operation.
Note To avoid losing any new settings, click Apply before changing the
IO Port parameter.
8-169
C281x GPIO Digital Input
Dialog
Box
8-170
C281x GPIO Digital Input
IO Port
Select the input/output port to use: GPIOPA, GPIOPB, GPIOPD,
GPIOPE, GPIOPF, or GPIOPG and select the I/O Port bits to enable
for digital input. (There is no GPIOPC port on the C281x.) If you
select multiple bits, vector input is expected. Cleared bits are
available for peripheral functionality. Multiple GPIO DI blocks
cannot share the same I/O port.
Note The input function of the digital I/O and the input path
to the related peripheral are always enabled on the board. If
you configure a pin as digital I/O, the corresponding peripheral
function cannot be used.
GPIO A MUX
8-171
C281x GPIO Digital Input
GPIO B MUX
Sample time
Time interval, in seconds, between consecutive input from the
pins.
Data type
Data type of the data to obtain from the GPIO pins. The data is
read as 16-bit integer data and then cast to the selected data type.
Valid data types are auto, double, single, int8, uint8, int16,
uint16, int32, uint32 or boolean.
8-172
C281x GPIO Digital Output
Description This block configures the general-purpose I/O (GPIO) registers that
control the GPIO shared pins for digital output. Each I/O port has one
MUX register, which is used to select peripheral operation or digital
I/O operation.
Note To avoid losing any new settings, click Apply before changing the
IO Port parameter.
8-173
C281x GPIO Digital Output
Dialog
Box
IO Port
Select the input/output port to use: GPIOPA, GPIOPB, GPIOPD,
GPIOPE, GPIOPF, or GPIOPG and select the I/O Port bits to enable
8-174
C281x GPIO Digital Output
Note The input function of the digital I/O and the input path
to the related peripheral are always enabled on the board. If
you configure a pin as digital I/O, the corresponding peripheral
function cannot be used.
GPIO A MUX
8-175
C281x GPIO Digital Output
GPIO B MUX
8-176
C281x PWM
Description F2812 DSPs include a suite of pulse width modulators (PWMs) used
to generate various signals. This block provides options to set the A
or B module Event Managers to generate the waveforms you require.
The twelve PWMs are configured in six pairs, with three pairs in each
module.
The C281x PWM module shares GP Timers with other C281 blocks. For
more information and guidance on sharing timers, see “Sharing General
Purpose Timers between C281x Peripherals” on page 1-15.
Note All inputs to the C281x PWM block must be scalar values.
8-177
C281x PWM
Module
Specify which target PWM pairs to use:
• A — Displays the PWMs in module A (PWM1/PWM2,
PWM3/PWM4, and PWM5/PWM6).
• B — Displays the PWMs in module B (PWM7/PWM8,
PWM9/PWM10, and PWM11/PWM12).
8-178
C281x PWM
Note All inputs to the C281x PWM block must be scalar values.
Waveform period
Period of the PWM waveform measured in clock cycles or in
seconds, as specified in the Waveform period units.
8-179
C281x PWM
8-180
C281x PWM
Outputs Pane
Enable PWM#/PWM#
Check to activate the PWM pair. PWM1/PWM2 are activated
via the Output 1 pane, PWM3/PWM4 are on Output 2, and
PWM5/PWM6 are on Output 3.
Duty cycle source
Select Specify via dialog to use the dialog box to enter a Duty
cycle value for the pair of PWM outputs. Select Input port to
use the input port, W#, to enter a Duty cycle value for the pair
of PWM outputs.
8-181
C281x PWM
Note All inputs to the C281x PWM block must be scalar values.
Duty cycle
Set the ratio of the PWM waveform pulse duration to the PWM
Waveform period.
Duty cycle units
Units for the duty cycle. Valid choices are Clock cycles and
Percentages. Changing these units changes the Duty cycle
value, and the Waveform period value and Waveform period
units selection.
8-182
C281x PWM
Logic Pane
8-183
C281x PWM
Input port adds an input port to the PWM block for setting the
C2000 ACTRx register. Each PWM uses 2 bits to set the following
options:
• 00 Forced Low
• 01 Active Low
• 10 Active High
• 11 Forced High
So that:
• PW1: Active High
• PW2: Active Low
• PW3: Active Low
• PW4: Active High
• PW5: Forced Low
• PW6: Forced High
8-184
C281x PWM
Deadband Pane
8-185
C281x PWM
Deadband prescaler
Number of clock cycles, which, when multiplied by the Deadband
period, determines the size of the deadband. Selectable values
are 1, 2, 4, 8, 16, and 32.
Deadband period source
Source from which the deadband period is obtained. Select
Specify via dialog to enter the values in the Deadband
period field or select Input port to use a value, in clock cycles,
from the input port.
Note All inputs to the C281x PWM block must be scalar values.
Deadband period
Value that, when multiplied by the Deadband prescaler,
determines the size of the deadband. Selectable values are from
1 to 15.
8-186
C281x PWM
8-187
C281x PWM
software (that is, the A/D conversion occurs when the ADC
block is executed in the software).
• Underflow interrupt — The EV generates an SOC signal for
the ADC associated with the same EV module when the board’s
general-purpose (GP) timer counter reaches a hexadecimal
value of FFFF.
• Period interrupt — The EV generates an SOC signal for the
ADC associated with the same EV module when the value in GP
timer matches the value in the period register. The value set in
Waveform period above determines the value in the register.
8-188
C281x QEP
Description Each F2812 Event Manager has three capture units, which can log
transitions on its capture unit pins. Event Manager A (EVA) uses
capture units 1, 2, and 3. Event Manager B (EVB) uses capture units
4, 5, and 6.
The quadrature encoder pulse (QEP) circuit decodes and counts
quadrature encoded input pulses on these capture unit pins. QEP
pulses are two sequences of pulses with varying frequency and a fixed
phase shift of 90 degrees (or one-quarter of a period). The circuit counts
both edges of the QEP pulses, so the frequency of the QEP clock is four
times the input sequence frequency.
The QEP, in combination with an optical encoder, is useful for obtaining
speed and position information from a rotating machine. Logic in the
QEP circuit determines the direction of rotation by which sequence is
leading. For module A, if the QEP1 sequence leads, the general-purpose
(GP) Timer counts up and if the QEP2 sequence leads, the timer counts
down. The pulse count and frequency determine the angular position
and speed.
The C281x QEP module shares GP Timers with other C281 blocks. For
more information and guidance on sharing timers, see “Sharing General
Purpose Timers between C281x Peripherals” on page 1-15.
8-189
C281x QEP
Dialog
Box
Module
Specify which QEP pins to use:
• A — Uses QEP1 and QEP2 pins.
8-190
C281x QEP
If you know the length of a clock cycle, you can easily calculate
how many clock cycles to set for the timer period. The following
calculation determines the length of one clock cycle:
8-191
C281x QEP
References For more information on the QEP module, consult the following
documents, available at the Texas Instruments Web site:
8-192
C281x SCI Receive
Purpose Receive data on target via serial communications interface (SCI) from
host
Description The C281x SCI Receive block supports asynchronous serial digital
communications between the target and other asynchronous peripherals
in nonreturn-to-zero (NRZ) format. This block configures the C281x
DSP target to receive scalar or vector data from the COM port via the
C28x target’s COM port.
Note For any given model, you can have only one C281x SCI Receive
block per module. There are two modules, A and B, which can be
configured through the Target Preferences block.
8-193
C281x SCI Receive
Dialog
Box
SCI module
SCI module to be used for communications.
Additional package header
This field specifies the data located at the front of the received
data package, which is not part of the data being received, and
generally indicates start of data. The additional package header
must be an ASCII value. You may use any string or number
(0–255). You must put single quotes around strings entered in
this field, but the quotes are not received nor are they included
in the total byte count.
8-194
C281x SCI Receive
Data type
Data type of the output data. Available options are single, int8,
uint8, int16, uint16, int32, or uint32.
Data length
How many of Data type the block will receive (not bytes).
Anything more than 1 is a vector. The data length is inherited
from the input (the data length originally input to the host-side
SCI Transmit block).
Initial output
Default value from the C281x SCI Receive block. This value is
used, for example, if a connection time-out occurs and the Action
taken when connection timeout field is set to “Output the last
received value”, but nothing yet has been received.
8-195
C281x SCI Receive
If you select "Output custom value", use the "Output value when
connection times out" field to set the custom value.
8-196
C281x SCI Receive
Sample time
Sample time, Ts, for the block’s input sampling. To execute this
block asynchronously, set Sample Time to -1, and refer to
“Asynchronous Interrupt Processing” on page 1-10 for a discussion
of block placement and other necessary settings.
Output receiving status
When this field is checked, the C281x SCI Receive block adds
another output port for the transaction status, and appears as
shown in the following figure.
8-197
C281x SCI Receive
References For detailed information on the SCI module, see TMS320x281x, 280x
DSP Serial Communication Interface (SCI) Reference Guide, Literature
Number SPRU051B, available at the Texas Instruments Web site.
8-198
C281x SCI Transmit
Purpose Transmit data from target via serial communications interface (SCI)
to host
Description
The C281x SCI Transmit block transmits scalar or vector data in int8
or uint8 format from the C281x target’s COM ports in nonreturn-to-zero
(NRZ) format. You can specify how many of the six target COM ports to
use. The sampling rate and data type are inherited from the input port.
The data type of the input port must be one of the following: single,
int8, uint8, int16, uint16, int32, or uint32. If no data type is specified,
the default data type is uint8.
Note For any given model, you can have only one C281x SCI Transmit
block per module. There are two modules, A and B, which can be
configured through the Target Preferences block.
8-199
C281x SCI Transmit
Dialog
Box
SCI module
SCI module to be used for communications.
Additional package header
This field specifies the data located at the front of the sent data
package, which is not part of the data being transmitted, and
generally indicates start of data. The additional package header
must be an ASCII value. You may use any string or number
(0–255). You must put single quotes around strings entered in
this field, but the quotes are not sent nor are they included in
the total byte count.
8-200
C281x SCI Transmit
References For detailed information on the SCI module, see TMS320x281x, 280x
DSP Serial Communication Interface (SCI) Reference Guide, Literature
Number SPRU051B, available at the Texas Instruments Web site.
8-201
C281x Software Interrupt Trigger
Description
When you add this block to a model, the block polls the input port for
the input value. When the input value is greater than the value in
Trigger software interrupt when input value is greater than, the
block posts the interrupt to a Hardware Interrupt block in the model.
8-202
C281x Software Interrupt Trigger
Dialog
Box
8-203
C281x Software Interrupt Trigger
8-204
C281x SPI Receive
8-205
C281x SPI Receive
Dialog
Box
Data length
Specify how many uint16s are expected to be received. Select
1 through 16.
Initial output
Set the value the SPI node outputs to the model before it has
received any data.
8-206
C281x SPI Receive
8-207
C281x SPI Transmit
Note For any given model, you can have only one C281x SPI Transmit
block per module. There are two modules, A and B, which can be
configured through the Target Preferences block.
8-208
C281x SPI Transmit
Dialog
Box
8-209
C281x SPI Transmit
8-210
C281x Timer
Description The C281x contains two event-manager (EV) modules. Each module
contains two general-purpose (GP) timers. You can use these timers as
independent time bases for various applications.
Use the C281x Timer block to set the periodicity of one GP timer and
the conditions under which it posts interrupts. Each model can contain
up to four C281x Timer blocks.
The C281x Timer module configures GP Timers that other C281 blocks
share. For more information and guidance on sharing timers, see
“Sharing General Purpose Timers between C281x Peripherals” on page
1-15.
8-211
C281x Timer
Dialog
Box
Module
Timer no
Select which of four possible timers to configure. Setting Module
to A lets you select Timer 1 or Timer 2 in Timer no. Setting
Module to B lets you select Timer 3 or Timer 4 in Timer no.
Clock source
When Timer no has a value of Timer 2 or Timer 4, use this
parameter to select the clock source for the event timer. You
8-212
C281x Timer
If you know the length of a clock cycle, you can easily calculate
how many clock cycles to set for the timer period. The following
calculation determines the length of one clock cycle:
8-213
C281x Timer
Counting mode
Select Up to generate an asymmetrical waveform output, or
Up-down to generate a symmetrical waveform output, as shown in
the following illustration.
8-214
C281x Timer
8-215
C28x Watchdog
Description This block configures the counter reset source of the Watchdog module
on the DSP.
Dialog
Box
Sample time
The interval at which the DSP resets the watchdog timer. When
you set this value to -1, the model inherits the sample time value
of the model. To execute this block asynchronously, set Sample
8-216
C28x Watchdog
8-217
Clarke Transformation
Id = Ia
Iq = (2 Ib + Ia) / 3
The inputs to this block are the phase a (As) and phase b (Bs)
components of the balanced three-phase quantities and the outputs
are the direct axis (Alpha) component and the quadrature axis (Beta)
of the transformed signal.
The instantaneous outputs are defined by the following equations and
are shown in the following figure:
8-218
Clarke Transformation
ia = I * sin(ωt)
ib = I * sin(ωt + 2π / 3)
ic = I * sin(ωt − 2π / 3)
id = I * sin(ωt)
iq = I * sin(ωt + π / 2)
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
8-219
Clarke Transformation
Dialog
Box
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, Literature Number SPRC080, available at the
Texas Instruments Web site.
8-220
Division IQN
Description This block divides two numbers that use the same Q format, using the
Newton-Raphson technique. The resulting quotient uses the same Q
format at the inputs.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Float to IQN, Fractional part IQN,
Fractional part IQN x int32, Integer part IQN, Integer part IQN x
int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x
IQN2, Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-221
Float to IQN
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Q value
Q value from 1 to 30 that specifies the precision of the output
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
8-222
Float to IQN
See Also Absolute IQN, Arctangent IQN, Division IQN, Fractional part IQN,
Fractional part IQN x int32, Integer part IQN, Integer part IQN x
int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x
IQN2, Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-223
Fractional part IQN
Description This block returns the fractional portion of an IQ number. The returned
value is an IQ number in the same IQ format.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN x int32, Integer part IQN, Integer part IQN x int32, IQN to
Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2, Magnitude
IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-224
Fractional part IQN x int32
Description This block multiplies an IQ input and a long integer input and returns
the fractional portion of the resulting IQ number.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Integer part IQN, Integer part IQN x int32, IQN to Float,
IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2, Magnitude IQN,
Saturate IQN, Square Root IQN, Trig Fcn IQN
8-225
From RTDX
Purpose Add RTDX communication channel for target to receive data from host
Description
Note This block will be removed from the Target Support Package
product in an upcoming release.
RTDX_enableInput(&channelname)
Note From RTDX blocks work only in code generation and when your
model runs on your target. In simulations, this block does not perform
any operations, except generating an output matching your specified
initial conditions.
8-226
From RTDX
To see more details about using RTDX in your model, refer to the
Embedded IDE Link User’s Guide and the following demos:
Note To use RTDX with the XDS100 USB JTAG Emulator and the
C28027 chip, add the following line to the linker command file:
_RTDX_interrupt_mask = ~0x000000008;
8-227
From RTDX
Dialog
Box
Channel name
Name of the input channel to be created by the generated code.
The channel name must meet C syntax requirements for length
and character content.
Enable blocking mode
Blocking mode instructs the target processor to pause processing
until new data is available from the From RTDX block. If you
enable blocking and new data is not available when the processor
needs it, your process stops. In nonblocking mode, the processor
uses old data from the block when new data is not available.
8-228
From RTDX
8-229
From RTDX
Data type
Type of data coming from the block. Select one of the following
types:
• Double — Double-precision floating-point values. This is the
default. Values range from -1 to 1.
• Single — Single-precision floating-point values ranging from
-1 to 1.
• Uint8 — 8-bit unsigned integers. Output values range from 0
to 255.
• Int16 — 16-bit signed integers. With the sign, the values range
from -32768 to 32767.
• Int32 — 32-bit signed integers. Values range from -231 to
(231-1).
Enable RTDX channel on start-up
Enables the RTDX channel when you start the channel from
MATLAB. With this selected, you do not need to use the enable
function in the Embedded IDE Link software to prepare your
RTDX channels. This option applies only to the channel you
specify in Channel name. You do have to open the channel.
References RTDX 2.0 User’s Guide, Literature Number: SPRUFC7, available from
the Texas Instruments Web site.
How to Write an RTDX Host Application Using MATLAB, Literature
Number: SPRA386, available from the Texas Instruments Web site.
8-230
Integer part IQN
Description This block returns the integer portion of an IQ number. The returned
value is a long integer.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN x int32,
IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-231
Integer part IQN x int32
Description This block multiplies an IQ input and a long integer input and returns
the integer portion of the resulting IQ number as a long integer.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, IQN to Float,
IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2, Magnitude IQN,
Saturate IQN, Square Root IQN, Trig Fcn IQN
8-232
Inverse Park Transformation
Id = ID * cos θ − IQ * sin θ
Iq = ID * sin θ + IQ * cos θ
The inputs to this block are the direct axis (Ds) and quadrature axis (Qs)
components of the transformed signal in the rotating frame and the
phase angle (Angle) between the stationary and rotating frames.
The outputs are the direct axis (Alpha) and the quadrature axis (Beta)
components of the transformed signal.
The variables used in the preceding figure and equations correspond to
the block variables as shown in the following table:
8-233
Inverse Park Transformation
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, Literature Number SPRC080, available at the
Texas Instruments Web site.
8-234
IQN to Float
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN x int32, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-235
IQN x int32
Description This block multiplies an IQ input and a long integer input and produces
an IQ output of the same Q value as the IQ input.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x IQN, IQN1 to IQN2, IQN1 x IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-236
IQN x IQN
Description This block multiplies two IQ numbers. Optionally, it can also round and
saturate the result.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Multiply option
Type of multiplication to perform:
• Multiply — Multiply the numbers.
• Multiply with Rounding — Multiply the numbers and round
the result.
8-237
IQN x IQN
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN1 to IQN2, IQN1 x IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-238
IQN1 to IQN2
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Q value
Q value from 1 to 30 that specifies the precision of the output
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
8-239
IQN1 to IQN2
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN1 to IQN2, IQN1 x IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-240
IQN1 x IQN2
Description This block multiples two IQ numbers when the numbers are represented
in different Q formats. The format of the result is specified in the dialog
box.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Q value
Q value from 1 to 30 that specifies the precision of the output
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
8-241
IQN1 x IQN2
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2,
Magnitude IQN, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-242
Magnitude IQN
a2 + b2
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
8-243
Magnitude IQN
IQN x int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2,
IQN1 x IQN2, Saturate IQN, Square Root IQN, Trig Fcn IQN
8-244
Park Transformation
ID = Id * cos θ + Iq * sin θ
IQ = − Id * sin θ + Iq * cos θ
8-245
Park Transformation
The inputs to this block are the direct axis (Alpha) and the quadrature
axis (Beta) components of the transformed signal and the phase angle
(Angle) between the stationary and rotating frames.
The outputs are the direct axis (Ds) and quadrature axis (Qs)
components of the transformed signal in the rotating frame.
The instantaneous inputs are defined by the following equations:
id = I * sin(ωt)
iq = I * sin(ωt + π / 2)
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, Literature Number SPRC080, available at the
Texas Instruments Web site.
8-246
PID Controller
Description This block implements a 32-bit digital PID controller with antiwindup
correction. The inputs are a reference input (ref) and a feedback input
(fdb) and the output (out) is the saturated PID output. The following
diagram shows a PID controller with antiwindup.
8-247
PID Controller
“up(t) = Kpe(t)”
where Kp is the proportional gain of the PID controller and e(t) is the
error between the reference and feedback inputs.
The integral term with saturation correction is
t
⎧Kp ⎫
ui (t) = ∫ ⎨
T
( )
e( ) + K c u( ) − u presat ( ) ⎬d
0⎩ i ⎭
where Kc is the integral correction gain of the PID controller.
The derivative term is
de(t)
ud (t) = K pTd
dt
u p[ n] = K p e[ n]
( )
ui[ n] = ui[ n − 1] + K i K p e[ n] + K c u[ n − 1] − u presat [ n − 1]
ud [ n] = K d K p ( e[ n] − e[ n − 1])
u presat [ n] = u p[ n] + ui[ n] + ud [ n]
(
u[ n] = SAT u presat [ n] )
8-248
PID Controller
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Proportional gain
Amount of proportional gain (Kp) to apply to the PID
Integral gain
Amount of gain (Ki) to apply to the integration equation
8-249
PID Controller
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, Literature Number SPRC080, available at the
Texas Instruments Web site.
8-250
Ramp Control
Description This block implements a ramp-up and ramp-down function. The input
is a target value and the outputs are the set point value (setpt) and
a flag. The flag output is set to 7FFFFFFFh when the output setpt
value reaches the input target value. The target and setpt values
are signed 32-bit fixed-point numbers with Q values between 16 and 29.
The flag is a long number.
The target value is compared with the setpt value. If they are not
equal, the output setpt is adjusted up or down by a fixed step size
(0.0000305).
If the fixed step size is relatively large compared to the target value,
the output may oscillate around the target value.
Dialog
Box
8-251
Ramp Control
8-252
Ramp Generator
Description This block generates ramp output (out) from the slope of the ramp
signal (gain), DC offset in the ramp signal (offset), and frequency of
the ramp signal (freq) inputs. All of the inputs and output are 32-bit
fixed-point numbers with Q values between 1 and 29.
Algorithm The block’s output (out) at the sampling instant k is governed by the
following algorithm:
For out(k) > 1, out(k) = out(k) - 1. For out(k) < -1, out(k) = out(k) + 1.
Angle(k) is defined as follows:
where m represents the fractional length of the data type of the inputs.
All math operations are carried out in fixed-point arithmetic, where the
fixed-point fractional length is determined by the block’s inputs.
8-253
Ramp Generator
Dialog
Box
Examples The following model demonstrates the Ramp Generator block. The
Constant and Scope blocks are available in Simulink Commonly Used
Blocks.
8-254
Ramp Generator
When you run the model, the Scope block generates the following output
(drag a zoom box around a portion of the output to change the display).
8-255
Ramp Generator
For example, if f_input = 0.001, the real value, 1, counts as fixed point
with a fractional length of 9:
8-256
Ramp Generator
When using fixed point with fractional length 9, the expected period
becomes:
Note If you use different fractional lengths for the fixed point
calculations, the output frequency varies depending on the precision.
8-257
Saturate IQN
Description This block saturates an input IQ number to the specified upper and
lower limits. The returned value is an IQ number of the same Q value
as the input.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Upper Limit
Maximum real-world value to which to saturate
Lower Limit
Minimum real-world value to which to saturate
8-258
Saturate IQN
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2,
IQN1 x IQN2, Magnitude IQN, Square Root IQN, Trig Fcn IQN
8-259
SCI Receive
Description
Specify the configuration of data being received from the target by
this block.
The data package being received is limited to 16 bytes of ASCII
characters, including package headers and terminators. Calculate
the size of a package by including the package header, or terminator,
or both, and the data size.
Acceptable data types are single, int8, uint8, int16, uint16, int32,
or uint32. The number of bytes in each data type is listed in the
following table:
For example, if your data package has package header ’S’ (1 byte) and
package terminator ’E’ (1 byte), that leaves 14 bytes for the actual data.
If your data is of type int8, there is room in the data package for 14
int8s. If your data is of type uint16, there is room in the data package
for 7 uint16s. If your data is of type int32, there is room in the data
package for only 3 int32s, with 2 bytes left over. Even though you
could fit two int8s or one uint16 in the remaining space, you may not,
because you cannot mix data types in the same package.
8-260
SCI Receive
The number of data types that can fit into a data package determine
the data length (see Data length in the Dialog Box description). In the
example just given, the 14 for data type int8 and the 7 for data type
uint16 are the data lengths for each data package, respectively. When
the data length exceeds 16 bytes, unexpected behavior, including run
time errors, may result.
Dialog
Box
Port name
You may configure up to four COM ports (COM1 through COM4)
for up to four host-side SCI Receive blocks.
8-261
SCI Receive
The input port of the SCI Transmit block accepts only one of these
values. Which value it accepts is inherited from the data type
from the input (the data length is also inherited from the input).
Data must consist of only one data type; you cannot mix types.
Data length
How many of Data type the block receives (not bytes). Anything
more than 1 is a vector. The data length is inherited from the
input (the data length input to the SCI Transmit block).
8-262
SCI Receive
Initial output
Default value from the SCI Receive block. This value is used,
for example, if a connection time-out occurs and the Action
taken when connection timeout field is set to “Output the last
received value”, but nothing yet has been received.
Action Taken when connection times out
Specify what to output if a connection time-out occurs. If “Output
the last received value” is selected, the last received value is what
is output, unless none has yet been received , in which case the
Initial output is considered the last received value.
If you select "Output custom value", use the "Output value when
connection times out" field to set the custom value.
Sample time
Determines how often the SCI Receive block is called (in seconds).
When you set this value to -1, the model inherits the sample
time value of the model. To execute this block asynchronously,
set Sample Time to -1, and refer to “Asynchronous Interrupt
Processing” on page 1-10 for a discussion of block placement and
other necessary settings.
Output receiving status
When this field is checked, the SCI Receive block adds another
output port for the transaction status, and appears as shown in
the following figure.
8-263
SCI Receive
• 0: No errors
• 1: A time-out occurred while the block was waiting to receive
data
• 2: There is an error in the received data (checksum error)
• 3: SCI parity error flag — Occurs when a character is received
with a mismatch
• 4: SCI framing error flag — Occurs when an expected stop bit
is not found
8-264
SCI Setup
Purpose Configure COM ports for host-side SCI Transmit and Receive blocks
Description
Standardize COM port settings for use by the host-side SCI Transmit
and Receive blocks. Setting COM port configurations globally with
the SCI Setup block avoids conflicts (e.g., the host-side SCI Transmit
block cannot use COM1 with settings different than those the COM1
used by the host-side SCI Receive block) and requires that you set
configurations only once for each COM port. The SCI Setup block is
a stand alone block.
Dialog
Box
8-265
SCI Setup
Communication Mode
Raw data or protocol. Raw data is unformatted and sent whenever
the transmitting side is ready to send, whether the receiving side
is ready or not. No deadlock condition can occur because there
is no wait state. Data transmission is asynchronous. With this
mode, it is possible the receiving side could miss data, but if the
data is noncritical, using raw data mode can avoid blocking any
processes.
Baud rate
Choose from 110, 300, 1200, 2400, 4800, 9600, 19200, 38400,
57600, or 115200.
Number of stop bits
Select 1 or 2.
8-266
SCI Setup
Parity mode
Select none, odd, or even.
Timeout
Enter any value greater than or equal to 0, in seconds. When the
COM port involved is using protocol mode, this value indicates
how long the transmitting side waits for an acknowledgement
from the receiving side or how long the receiving side waits for
data. The system displays a warning message if the time-out
is exceeded, every n number of seconds, n being the value in
Timeout.
8-267
SCI Transmit
Description
Specify the configuration of data being transmitted to the target from
this block.
The data package being sent is limited to 16 bytes of ASCII characters,
including package headers and terminators. Calculate the size of a
package by figuring in package header, or terminator, or both, and
the data size.
Acceptable data types are single, int8, uint8, int16, uint16, int32,
or uint32. The byte size of each data type is as follows:
For example, if your data package has package header “S” (1 byte) and
package terminator “E” (1 byte), that leaves 14 bytes for the actual data.
If your data is of type int8, there is room in the data package for 14
int8s. If your data is of type uint16, there is room in the data package
for only 7 uint16s. If your data is of type int32, there is room in the
data package for only 3 int32s, with 2 bytes left over. Even though you
could fit two int8s or one uint16 in the remaining space, you may not,
because you cannot mix data types in the same package.
8-268
SCI Transmit
The number of data types that can fit into a data package determine
the data length (see Data length in the Dialog Box description). In
the example just given, the 14 for data type int8 and the 7 for data
type uint16 are the data lengths for each data package, respectively.
When the data length exceeds 16 bytes, unexpected behavior, including
run time errors, may result.
Dialog
Box
Port name
You may configure up to four COM ports (COM1 through COM4)
for up to four host-side SCI Transmit blocks.
Additional package header
This field specifies the data located at the front of the transmitted
data package, which is not part of the data being transmitted, and
generally indicates start of data. The additional package header
must be an ASCII value. You may use any string or number
(0–255). You must put single quotes around strings entered in
this field, but the quotes are not sent nor are they included in
the total byte count.
8-269
SCI Transmit
8-270
Space Vector Generator
The alpha and beta components are transformed via the inverse Clarke
equation and projected into reference phase voltages. These voltages
are represented in the outputs as the duty ratios of the PWM1 (Ta),
PWM3 (Tb), and PWM5 (Tc).
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
8-271
Space Vector Generator
Dialog
Box
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, Literature Number SPRC080, available at the
Texas Instruments Web site.
8-272
Speed Measurement
Description This block calculates the motor speed based on the rotor position when
the direction information is available. The inputs are the electrical
angle (theta) and the direction of rotation (dir) from the encoder. The
outputs are the speed normalized from 0 to 1 in the Q format (freq) and
the speed in revolutions per minute (rpm).
When the motor spins at a constant speed, theta (in counts) from your
position sensor (encoder) should increase linearly from 0 to 1 and then
abruptly return to 0, like a saw-shaped signal. Adjust the theta signal
output from your encoder to get the correct input signal range for the
Speed Measurement block. Then, convert your encoder signal to 32-bit
fixed-point Q format that meets your resolution needs.
For example, if you are using a position sensor that generates 8000
counts for one full revolution of the motor, (0.0450 degrees per count),
8-273
Speed Measurement
you need to reset your counter to 0 after your counter reaches 8000.
Each time you read your encoder position, you need to convert the
position to a 32-bit, fixed-point Q format value knowing that 8000 is
represented as a 1.0. In this example your format could be Q31.
8-274
Speed Measurement
rate, you must take at least one sample for each revolution. For a motor
with base speed equal to 1000 rpm, which is 16.67 rps, you need to
sample at 1/16.67 s, which is 0.06 s/sample. This sample rate of 16.67
samples per second is the maximum sample time (lowest sample rate)
that assures you can measure the full speed of the motor.
Using the same sample rate assumption, the minimum speed the block
can measure depends on the encoder counts per revolution. At the
minimum measurable motor speed, the encoder generates one count per
sample period—16.67 counts per second. For an encoder that generates
8000 counts per revolution, this results in being able to measure a speed
of [(16.67 counts/s) * (0.045 degrees/count)] = 0.752 degrees per second,
or about 45 degrees per minute—one-eighth RPM.
8-275
Speed Measurement
Dialog
Box
Base speed
Maximum speed of the motor to measure in revolutions per
minute.
Differentiator constant
Constant used in the differentiator equation that describes the
rotor position.
Low-pass filter constant
Constant to apply to the lowpass filter. This constant is
1/(1+T*(2πfc)), where T is the sampling period and fc is the cutoff
frequency. The 1/(2πfc) term is the lowpass filter time constant.
This block uses a lowpass filter to reduce noise generated by the
differentiator.
Example The following example demonstrates how you configure the Speed
Measurement block.
8-276
Speed Measurement
3 Set the value for Base Speed to the maximum speed to measure, in
revolutions per minute.
1 Open the block dialog box for the block before the Speed Measurement
block in your model (the upstream or driving block).
2 Set the sample time parameter in the upstream block according to the
sample time guidelines described in The Sample Time Calculation.
References For detailed information on the DMC library, see C/F 28xx Digital
Motor Control Library, SPRC080, available at the Texas Instruments
Web site.
8-277
Square Root IQN
Description This block calculates the square root or inverse square root of an IQ
number and returns an IQ number of the same Q format. The block
uses table lookup and a Newton-Raphson approximation.
Negative inputs to this block return a value of zero.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Function
Whether to calculate the square root or inverse square root
• Square root (_sqrt) — Compute the square root.
• Inverse square root (_isqrt) — Compute the inverse
square root.
8-278
Square Root IQN
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2,
IQN1 x IQN2, Magnitude IQN, Saturate IQN, Trig Fcn IQN
8-279
To RTDX
Purpose Add RTDX communication channel to send data from target to host
Description
Note This block will be removed from the Target Support Package
product in an upcoming release.
RTDX_enableOutput(&channelname)
Note To RTDX blocks work only in code generation and when your
model runs on your target. In simulations, this block does not perform
any operations.
8-280
To RTDX
To see more details about using RTDX in your model, refer to the
Embedded IDE Link User’s Guide and the following demos:
Note To use RTDX with the XDS100 USB JTAG Emulator and the
C28027 chip, add the following line to the linker command file:
_RTDX_interrupt_mask = ~0x000000008;
8-281
To RTDX
Dialog
Box
Channel name
Name of the output channel to be created by the generated code.
The channel name must meet C syntax requirements for length
and character content.
Enable blocking mode
Enables blocking mode (selected by default). In blocking mode,
writing a message is suspended while the RTDX channel is busy,
that is, when data is being written in either direction. The code
waits at the RTDX_write call site while the channel is busy. Any
interrupt of the higher priority will temporary divert the program
execution from this site, but it will eventually come back and wait
until the channel stops writing.
8-282
To RTDX
References RTDX 2.0 User’s Guide, Literature Number: SPRUFC7, available from
the Texas Instruments Web site.
How to Write an RTDX Host Application Using MATLAB, Literature
Number: SPRA386, available from the Texas Instruments Web site.
8-283
Trig Fcn IQN
Description This block calculates basic trigonometric functions and returns the
result as an IQ number. Valid Q values for _IQsinPU and _IQcosPU are
1 to 30. For all others, valid Q values are from 1 to 29.
Note The implementation of this block does not call the corresponding
Texas Instruments library function during code generation. The TI
function uses a global Q setting and the &tm_mathworks_without_the;
code used by this block dynamically adjusts the Q format based on
the block input. See Chapter 4, “Using the IQmath Library” for more
information.
Dialog
Box
Function
Type of trigonometric function to calculate:
• _IQsin — Compute the sine (sin(A)), where A is in radians.
• _IQsinPU — Compute the sine per unit (sin(2*pi*A)), where
A is in per-unit radians.
• _IQcos — Compute the cosine (cos(A)), where A is in radians.
8-284
Trig Fcn IQN
References For detailed information on the IQmath library, see the user’s guide for
the C28x IQmath Library - A Virtual Floating Point Engine, Literature
Number SPRC087, available at the Texas Instruments Web site. The
user’s guide is included in the zip file download that also contains the
IQmath library (registration required).
See Also Absolute IQN, Arctangent IQN, Division IQN, Float to IQN, Fractional
part IQN, Fractional part IQN x int32, Integer part IQN, Integer part
IQN x int32, IQN to Float, IQN x int32, IQN x IQN, IQN1 to IQN2,
IQN1 x IQN2, Magnitude IQN, Saturate IQN, Square Root IQN
8-285
Trig Fcn IQN
8-286
Index
A
Index C280x/C2802x/C2803x/C28x3x GPIO Digital
Absolute IQN block 8-2 Input 8-92
acquisition window C280x/C2802x/C2803x/C28x3x GPIO Digital
ADC blocks Output 8-95
ACQ_PS 3-2 C280x/C2802x/C2803x/C28x3x I2C Receive
ADC block 8-5 block 8-98
ADC blocks C280x/C2802x/C2803x/C28x3x I2C Transmit
C281x 8-145 block 8-102
Arctangent IQN block 8-3 C280x/C2802x/C2803x/C28x3x SCI Receive
ASAP2 files, generating 2-19 block 8-105
asymmetric vs. symmetric waveforms 8-179 C280x/C2802x/C2803x/C28x3x SCI Transmit
asynchronous interrupt processing 1-10 block 8-112
C280x/C2802x/C2803x/C28x3x Software
Interrupt Trigger 8-115
B C280x/C2802x/C2803x/C28x3x SPI Receive
blocks block 8-118
adding to model 1-32 C280x/C2802x/C2803x/C28x3x SPI Transmit
CAN Calibration Protocol 8-13 block 8-121
recommendations 1-25 C280x/C2803x/C28x3x eCAN Receive block 8-19
C280x/C2803x/C28x3x eCAN Transmit
block 8-25
C
C280x/C2803x/C28x3x ePWM block 8-40
C2000 Library C280x/C2803x/C28x3x eQEP block 8-74
SCI Receive C281x ADC block 8-145
Host-side 8-260 C281x CAP block 8-150
SCI Setup C281x eCAN Receive block 8-159
Host-side 8-265 C281x eCAN Transmit block 8-165
SCI Transmit C281x GPIO Digital Input block 8-169
Host-side 8-268 C281x GPIO Digital Output block 8-173
c2000lib startup 1-30 C281x PWM block 8-177
C2802x ADC 8-126 C281x QEP block 8-189
C2802x COMP 8-124 C281x SCI Receive block 8-193
C2802x/C2803x AnalogIO Input 8-132 C281x SCI Transmit block 8-199
C2802x/C2803x AnalogIO Output 8-134 C281x Software Interrupt Trigger 8-202
C2803x ADC 8-126 C281x SPI Receive block 8-205
C2803x COMP 8-124 C281x SPI Transmit block 8-208
C2803x LIN Receive block 8-136 C281x Timer block 8-211
C2803x LIN Transmit block 8-142 C28x3x GPIO Digital Input 8-92
C280x/C2802x/C2803x/C28x3x eCAP block 8-29 C28x3x GPIO Digital Output 8-95
CAN Calibration Protocol block 8-13
Index-1
Index
Index-2
Index
Index-3
Index
Index-4
Index
W
waveforms 8-179
Index-5