C28x Microcontroller ODW 2-0
C28x Microcontroller ODW 2-0
Important Notice
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or
to discontinue any product or service without notice, and advise customers to obtain the latest
version of relevant information to verify, before placing orders, that information being relied on is
current and complete. All products are sold subject to the terms and conditions of sale supplied at
the time of order acknowledgment, including those pertaining to warranty, patent infringement,
and limitation of liability.
TI warrants performance of its semiconductor products to the specifications applicable at the time
of sale in accordance with TI’s standard warranty. Testing and other quality control techniques
are utilized to the extent TI deems necessary to support this warranty. Specific testing of all
parameters of each device is not necessarily performed, except those mandated by government
requirements.
In order to minimize risks associated with the customer’s applications, adequate design and
operating safeguards must be provided by the customer to minimize inherent or procedural
hazards.
TI assumes no liability for applications assistance or customer product design. TI does not
warrant or represent that any license, either express or implied, is granted under any patent right,
copyright, mask work right, or other intellectual property right of TI covering or relating to any
combination, machine, or process in which such semiconductor products or services might be or
are used. TI’s publication of information regarding any third party’s products or services does not
constitute TI’s approval, warranty or endorsement thereof.
Revision History
April 2014 – Revision 1.0
October 2014 – Revision 1.1
November 2016 – Revision 2.0
Mailing Address
Texas Instruments
C2000 Technical Training
13905 University Boulevard
Sugar Land, TX 77479
Workshop Topics
Workshop Topics ......................................................................................................................... 3
Workshop Introduction ................................................................................................................. 5
Outline ...................................................................................................................................... 5
Required Workshop Materials .................................................................................................. 6
F28379D LaunchPad ............................................................................................................... 6
F28x7x Piccolo / Delfino Comparison ...................................................................................... 7
Architectural Overview ................................................................................................................. 8
F2837xD Block Diagram .......................................................................................................... 8
Simplified F28x7x Memory Map ............................................................................................... 9
Interrupt Response Manager ................................................................................................. 10
Direct Memory Access (DMA) ................................................................................................ 10
Control Law Accelerator (CLA) .............................................................................................. 11
Viterbi / Complex Math Unit (VCU) ........................................................................................ 11
Trigonometric Math Unit (TMU).............................................................................................. 12
External Memory Interface (EMIF) ......................................................................................... 12
Communication Peripherals ................................................................................................... 13
On-Chip Safety Features ....................................................................................................... 13
Programming Development Environment .................................................................................. 14
Programming Model ............................................................................................................... 14
Code Composer Studio .......................................................................................................... 15
Software Development and COFF Concepts......................................................................... 15
Edit and Debug Perspective................................................................................................... 17
Target Configuration .............................................................................................................. 18
CCS Project and Build Options .............................................................................................. 19
CCSv6 Debug Environment ................................................................................................... 22
Dual Subsystem Debug ......................................................................................................... 24
Lab File Directory Structure ................................................................................................... 25
Lab 1: Dual-Core Debug with F2837xD ..................................................................................... 26
Reset, Interrupts and System Initialization................................................................................. 33
Reset Sources ........................................................................................................................ 33
Boot Process .......................................................................................................................... 33
Emulation Boot Mode ............................................................................................................. 34
Stand-Alone Boot Mode ......................................................................................................... 35
Reset Code Flow – Summary ................................................................................................ 36
Interrupt Sources .................................................................................................................... 36
Peripheral Interrupt Expansion – PIE ..................................................................................... 38
F2837xD PIE Assignment Table ............................................................................................ 38
PIE Block Initialization ............................................................................................................ 40
F2837xD Dual-Core Interrupt Structure ................................................................................. 41
F28x7x Oscillator / PLL Clock Module ................................................................................... 42
Watchdog Timer Module ........................................................................................................ 43
F28x7x General-Purpose Input-Output .................................................................................. 44
GPIO Input X-Bar ................................................................................................................... 45
GPIO Output X-Bar ................................................................................................................ 46
Analog Subsystem ..................................................................................................................... 48
ADC Subsystem ..................................................................................................................... 48
ADC Module Block Diagram .................................................................................................. 49
ADC Triggering ...................................................................................................................... 50
ADC Conversion Priority ........................................................................................................ 51
Post Processing Block ........................................................................................................... 52
Comparator Subsystem ......................................................................................................... 54
Workshop Introduction
Outline
Outline
Workshop Introduction
Architectural Overview
Programming Development Environment
Lab 1: Using Code Composer Studio with the F2837xD
Reset,Interrupts and System Initialization
Analog Subsystem
Lab 2: Configuring the ADC as a data acquisition system
Control Peripherals
Lab 3: Generating a PWM waveform
Inter-Processor Communications (IPC)
Lab 4: Data transfer using Inter-Processor Communications
Support Resources
Student Guide
F28379D LaunchPad
F28379D LaunchPad
JP3: 5V JP2: GND D10: GPIO31 (blue) S1: Boot TMS320F28379D
from USB from USB D9: GPIO34 (red) Modes
(disables (disables
isolation) isolation) D1: Power (green) J2/J4 * S3: Reset J6/J8 *
J14:
QEP_A
emulation circuitry
XDS100v2
J15:
QEP_B
J12:
CAN
CON1: USB JP1: 3.3V J1/J3 * J21 J20/J19 JP4/JP5 J5/J7 * J13/J11
emulation/ from USB (ADC-D (Optional SMA (connects I2C
UART (disables differential connector point) 3.3V/5V
isolation) pair inputs) to J5/J7)
* = BoosterPack plug-in module connector Note: F28379D – 337 pin package
Architectural Overview
F2837xD Block Diagram
F2837xD – Dual Core Block Diagram
CMPSS
PIE McBSP
32x32 bit R-M-W Interrupt
TMU Manager I2C
Multiplier Atomic CLA
FPU ALU VCU SCI
3
SPI
Watchdog 32-bit
Register Bus Timers CAN 2.0B
CPU
USB 2.0
Data Bus GPIO
context save
Auto Context Save
T ST0
AH AL
PH PL
AR1 (L) AR0 (L)
DP ST1
DBSTAT IER
PC(msw) PC(lsw)
DMA SPI
GS0 RAM 6-channels
Triggers PWM1
GS15 RAM PWM2
ADCA/B/C/D (1-4, EVT)
IPC RAM MXEVTA/B MREVTA/B
XINT1-5 TINT0-2 PWM11
ePWM1-12 (SOCA-B) PWM12
SD1FLT1-4 SD2FLT1-4
EMIF SPITX/RX (A-C)
USBA_EPx_RX/TX1-3
software
y = r * sin(rad)
y
r
x
calculating common
Trigonometric operations
x = r * cos(rad)
Operation Instruction Exe Cycles Result Latency FPU Cycles w/o TMU
Z = Y/X DIVF32 Rz,Ry,Rx 1 5 ~24
Y = sqrt(X) SQRTF32 Ry,Rx 1 5 ~26
Y = sin(X/2pi) SINPUF32 Ry,Rx 1 4 ~33
Y = cos(X/2pi) COSPUF32 Ry,Rx 1 4 ~33
Y = atan(X)/2pi ATANPUF32 Ry,Rx 1 4 ~53
Instruction To QUADF32 Rw,Rz,Ry,Rx 3 11 ~90
Support ATAN2 ATANPUF32 Ra,Rz
Calculation ADDF32 Rb,Ra,Rw
Y = X * 2pi MPY2PIF32 Ry,Rx 1 2 ~4
Y = X * 1/2pi DIV2PIF32 Ry,Rx 1 2 ~4
CPU1
CPU1
CPU1.DMA1 16/32-Bit 16-Bit
Arbiter/ Interface Arbiter/ Interface
Memory EMIF1 Memory EMIF2
CPU2
Protection CPU1.CLA1 Protection
CPU2.DMA1
Communication Peripherals
Communication Peripherals
Four Serial Communication Interfaces (SCI)
with 16-level deep TX/RX FIFOs
Three Serial Peripheral Interfaces (SPI) with
16-level deep TX/RX FIFOs
Two Inter-Integrated Circuit Interfaces (I2C)
with 16-level deep TX/RX FIFOs
Two Multi-channel Buffered Serial Ports
(McBSP) with double-buffered TX and triple-
buffered RX
Two Controller Area Network Ports (CAN)
with 32 mailboxes each
One USB + PHY port
Annunciation
Single error pin for external signalling of error
simplifies programming
Bit Fields Bit Field Header Files
C structures – Peripheral
Register Header Files
Direct Register access whole or by
bits and bit fields are
manipulated without masking
Registers and Addresses Ease-of-use with CCS IDE
Direct Register Access
User code (C or assembly)
Hardware defines and access register
addresses
*CMPR1 = 0x1234;
The device support package includes documentation and examples showing how to
use the Bit Field Header Files or DriverLib
Device support packages located at: C:\TI\controlSUITE\device_support\
controlSUITE can be downloaded at www.ti.com\controlSUITE
CCS is based on the Eclipse open source software framework. The Eclipse software framework
was originally developed as an open framework for creating development tools. Eclipse offers an
excellent software framework for building software development environments and it is becoming
a standard framework used by many embedded software vendors. CCS combines the
advantages of the Eclipse software framework with advanced embedded debug capabilities from
TI resulting in a compelling feature-rich development environment for embedded developers.
CCS supports running on both Windows and Linux PCs. Note that not all features or devices are
supported on Linux.
Each file of code, called a module, may be written independently, including the specification of all
resources necessary for the proper operation of the module. Modules can be written using CCS
or any text editor capable of providing a simple ASCII file output. The expected extension of a
source file is .ASM for assembly and .C for C programs.
Development
Tool
Asm Link Debug
External
Editor Libraries Graphs, Emulator
Profiling
MCU
Board
Code Composer Studio includes:
Integrated
Edit/Debug GUI
Code Generation Tools
TI-RTOS
CCS includes a built-in editor, compiler, assembler, linker, and an automatic build process.
Additionally, tools to connect file input and output, as well as built-in graph displays for output are
available. Other features can be added using the plug-ins capability
Numerous modules are joined to form a complete program by using the linker. The linker
efficiently allocates the resources available on the device to each module in the system. The
linker uses a command (.CMD) file to identify the memory resources and placement of where the
various sections within each module are to go. Outputs of the linking process includes the linked
object file (.OUT), which runs on the device, and can include a .MAP file which identifies where
each linked section is located.
The high level of modularity and portability resulting from this system simplifies the processes of
verification, debug and maintenance. The process of COFF development is presented in greater
detail in the following paragraphs.
The concept of COFF tools is to allow modular development of software independent of hardware
concerns. An individual assembly language file is written to perform a single task and may be
linked with several other tasks to achieve a more complex total system.
Writing code in modular form permits code to be developed by several people working in parallel
so the development cycle is shortened. Debugging and upgrading code is faster, since
components of the system, rather than the entire system, is being operated upon. Also, new
systems may be developed more rapidly if previously developed modules can be used in them.
Code developed independently of hardware concerns increases the benefits of modularity by al-
lowing the programmer to focus on the code and not waste time managing memory and moving
code as other code components grow or shrink. A linker is invoked to allocate systems hardware
to the modules desired to build a system. Changes in any or all modules, when re-linked, create
a new hardware allocation, avoiding the possibility of memory resource conflicts.
Target Configuration
A Target Configuration tells CCS how to connect to the device. It describes the device using GEL
files and device configuration files. The configuration files are XML files and have a *.ccxlm file
extension.
CCSv6 Project
List of files:
Source (C, assembly)
Libraries
SYS/BIOS configuration file
Linker command files
Project settings:
Build options (compiler,
assembler, linker, and
TI-RTOS)
Build configurations
To create a new project, you need to select the following menu items:
Along with the main Project menu, you can also manage open projects using the right-click popup
menu. Either of these menus allows you to modify a project, such as add files to a project, or
open the properties of a project to set the build options.
A graphical user interface (GUI) is used to assist in creating a new project. The GUI is shown in
the slide below.
Project options direct the code generation tools (i.e. compiler, assembler, linker) to create code
according to your system’s needs. When you create a new project, CCS creates two sets of build
options – called configurations: one called Debug, the other Release (you might think of as
optimize).
To make it easier to choose build options, CCS provides a graphical user interface (GUI) for the
various compiler and linker options. The following slide is a sample of the configuration options.
There is a one-to-one relationship between the items in the text box on the main page and the
GUI check and drop-down box selections. Once you have mastered the various options, you can
probably find yourself just typing in the options.
There are many linker options but these four handle all of the basic needs.
• -o <filename> specifies the output (executable) filename.
• -m <filename> creates a map file. This file reports the linker’s results.
• -c tells the compiler to autoinitialize your global and static variables.
• -x tells the compiler to exhaustively read the libraries. Without this option libraries are
searched only once, and therefore backwards references may not be resolved.
To help make sense of the many compiler options, TI provides two default sets of options (con-
figurations) in each new project you create. The Release (optimized) configuration invokes the
optimizer with –o3 and disables source-level, symbolic debugging by omitting –g (which disables
some optimizations to enable debug).
Linker
Categories for linking – specify various link options
${PROJECT_ROOT} specifies the current project directory
The common debugging and program execution descriptions are shown below:
Start debugging
New Target Creates a new target configuration file. File New Menu
Configuration Target Menu
Program execution
Assembly The debugger executes the next assembly instruc- TI Explicit Stepping Toolbar
Step Into tion, whether source is available or not. Target Advanced Menu
Note: CCSv6 will automatically add ALL files contained in the folder where the project is created
Note: The lab exercises in this workshop have been developed and targeted for the F28379D
LaunchPad. Optionally, the F28379D Experimenter Kit can be used. Other F2807x or
F2837xS development tool kits may be used and might require some minor modifications
to the lab code and/or lab directions; however the Inter-Processor Communications lab
exercise will require either the F28379D LaunchPad or the F28379D Experimenter Kit.
Refer to Appendix A for additional information about the F28379D Experimenter Kit.
• F28379D LaunchPad:
Using the supplied USB cable – plug the USB Standard Type A connector into the computer USB
port and the USB Mini Type B connector into the LaunchPad. This will power the LaunchPad
using the power supplied by the computer USB port. Additionally, this USB port will provide the
JTAG communication link between the device and Code Composer Studio.
At the beginning of the workshop, boot mode switch S1 position 3 must be set to “1 – ON”. This
will configure the device for emulation boot mode.
Procedure
This folder contains all CCS custom settings, which includes project settings and views when
CCS is closed so that the same projects and settings will be available when CCS is opened
again. The workspace is saved automatically when CCS is closed.
2. The first time CCS opens, an introduction page appears. Close the page by clicking the X on
the “Getting Started” tab. You should now have an empty workbench. The term “workbench”
refers to the desktop development environment. Maximize CCS to fill your screen.
The workbench will open in the “CCS Edit” perspective view. Notice the CCS Edit icon in the
upper right-hand corner. A perspective defines the initial layout views of the workbench
windows, toolbars, and menus which are appropriate for a specific type of task (i.e. code
development or debugging). This minimizes clutter to the user interface. The “CCS Edit”
perspective is used to create or build C/C++ projects. A “CCS Debug” perspective view will
automatically be enabled when the debug session is started. This perspective is used for
debugging C/C++ projects.
In the file name field type F2837xD.ccxml. This is just a descriptive name since multiple
target configuration files can be created. Leave the “Use shared location” box checked and
select Finish.
4. In the next window that appears, select the emulator using the “Connection” pull-down list
and choose “Texas Instruments XDS100v2 USB Debug Probe”. In the “Board or Device” box
type F28379D to filter the options. In the box below, check the box to select “F28379D”.
Click Save to save the configuration, then close the “F2837xD.ccxml” set up window by
clicking the X on the tab.
5. To view the target configurations, click:
and click the plus sign (+) to the left of “User Defined”. Notice that the F2837xD.ccxml file is
listed and set as the default. If it is not set as the default, right-click on the .ccxml file and
select “Set as Default”. Close the Target Configurations window by clicking the X on the tab.
A CCS Project window will open. At the top of this window, filter the “Target” options by using
the pull-down list on the left and choose “2837xD Delfino”. In the pull-down list immediately
to the right, choose the “TMS320F28379D” device.
Leave the “Connection” box blank since we already set up the target configuration.
7. The next section selects the project settings. In the Project name field type Lab1_cpu01.
Uncheck the “Use default location” box. Click the Browse… button and navigate to:
C:\F2837xD\Labs\Lab1\cpu01
Click OK.
8. Next, open the “Advanced setting” section and set the “Linker command file” to “<none>”.
We will be using our own linker command file, rather than the one supplied by CCS.
9. Then, open the “Project templates and examples” section and select the “Empty Project”
template. Click Finish.
A new project has now been created. Notice the “Project Explorer” window contains
Lab1_cpu01. The project is set Active and the output files will be located in the Debug folder.
At this point, the project does not include any source files. The next step is to add the source
files to the project.
Note: The local copy of the supporting files and libraries in this workshop are identical to the
required controlSUITE files. The workshop lab exercises will make use of these files as
often as possible. When adding files to the project, a window will appear asking to “copy”
or “link” the files. Selecting “Copy files” will make a copy of the original file to work with in
the local project directory. Selecting “Link files” will set a reference to the original file and
will use the original file. Typically, “link files” is used when the files will not be modified.
To avoid accidently modifying the original files, we will use “copy files” throughout this
workshop and work with the local copy in the project directory.
For convenience, all of the needed source files for this lab exercise are located in the same
folder.
10. To add the source files to the project, right-click on Lab1_cpu01 in the “Project Explorer”
window and select:
Add Files…
2837xD_RAM_lnk_cpu1.cmd F2837xD_PieCtrl.c
F2837xD_CodeStartBranch.asm F2837xD_PieVect.c
F2837xD_DefaultISR.c F2837xD_SysCtrl.c
F2837xD_GlobalVariableDefs.c F2837xD_usDelay.asm
F2837xD_Gpio.c Lab1_cpu01.c
F2837xD_Headers_nonBIOS_cpu1.cmd
In the Project Explorer window, click the plus sign (+) to the left of Lab1_cpu01 and notice
that the files are listed.
${PROJECT_ROOT}/../../../Device_support/F2837xD_headers/include
${PROJECT_ROOT}/../../../Device_support/F2837xD_common/include
Since CPU1 has control over all the IO pins, GPIO31 can be manipulated directly by CPU1.
However, for this lab exercise, we would like to have CPU2 control GPIO34 so it can blink
D9. This will be accomplished using the IPC (Inter-Processor Communications) module on
the device. The function calls are used here to set up the GPIO pin so it is ready for CPU2
to use.
14. At the bottom of function main() is an infinite “for” loop. The instructions inside the loop blink
LED D10 on the LaunchPad at a rate determined by the DELAY_US() macro. The LED
status is changed by the code lines which write to the GPIO31 pin.
15. CCS contains an outline viewer which displays the components of each source file. Open the
outline viewer by clicking:
View Outline
Notice that the outline window contents change as each source file is viewed in the editor.
For the source file “Lab1_cpu01” the outline window contains:
The list is short since this is a very simple project, but for more complex source files the
“Outline” view provides a useful way of finding symbols and function calls within the file.
2837xD_RAM_lnk_cpu2.cmd F2837xD_PieCtrl.c
F2837xD_CodeStartBranch.asm F2837xD_PieVect.c
F2837xD_DefaultISR.c F2837xD_SysCtrl.c
F2837xD_GlobalVariableDefs.c F2837xD_usDelay.asm
F2837xD_Gpio.c Lab1_cpu02.c
F2837xD_Headers_nonBIOS_cpu2.cmd
Note: In CCS the on-chip flash programmer is integrated into the debugger. When the program is
loaded CCS will automatically determine which sections reside in flash memory based on the
linker command file. CCS will then program these sections into the on-chip flash memory.
Additionally, in order to effectively debug with CCS, the symbolic debug information (e.g., symbol
and label addresses, source file links, etc.) will automatically load so that CCS knows where
everything is in your code. In this lab exercise, code will be running from RAM only.
19. In the Project Explorer window click on the “Lab1_cpu01” project to set it active. Then click
the “Build” button (hammer) and watch the tools run in the “Console” window. Check for any
errors in the “Problems” window. Repeat this step for the “Lab1_cpu02” project.
20. Again, in the Project Explorer window click on the “Lab1_cpu01” project to set it active. CCS
in the “CCS Edit” perspective view can automatically save modified source files, build the
program, open the “CCS Debug” perspective view, connect and download it to the target
(load RAM memory or program flash memory), and then run the program to the beginning
main(), in a single step.
Click on the “Debug” button (green bug) or click RUN Debug
A Launching Debug Session window will open. Select only CPU1 to load the program on,
and then click OK.
The CCS Debug icon in the upper right-hand corner indicates that we are now in the “CCS
Debug” perspective view. The program ran through the C-environment initialization routine in
the run-time support library and stopped at “main()” in Lab1_cpu01.c. The blue arrow in the
left hand column of the source code window indicates the current position of the CPU1
program counter (PC). The “Debug” window reflects the current status of CPU1 and CPU2.
Notice that CPU1 is currently connected and CPU2 is “Disconnected”. This means that CCS
has no control over CPU2 thus far; it is freely running from the view of CCS. Of course CPU2
is under control of CPU1 and since we have not executed an Inter Processor Communication
(IPC) command yet, CPU2 is stopped by an “Idle” mode instruction in the Boot ROM.
21. Next, we need to connect to and load the program on CPU2. Right-click at the line “Texas
Instruments XDS100v2 USB Debug Probe_0/C28xx_CPU2” and select “Connect Target”.
22. With the line “Texas Instruments XDS100v2 USB Debug Probe_0/C28xx_CPU2” still
highlighted, load the program:
View Expressions on the menu bar). In the Expression window an ampersand, which
means the “address of”, is not used. The Expressions window knows we are specifying a
symbol.
24. In main() for each CPU there is a counter which keeps track of the number of times each LED
has changed state. We will monitor these variables. In the empty box in the “Expression”
column (click on the text “Add new expression”), type ToggleCount1 and then enter.
25. Repeat the above step to add the variable ToggleCount2 to the Expressions window.
26. In the Debug window, click on the line “Texas Instruments XDS100v2 USB Debug
Probe_0/C28xx_CPU1”. Then run the code on CPU1 by clicking the green “Resume” button.
LED D10 on the LaunchPad should now be blinking at approximately 1Hz.
27. In the Debug window, click on the line “Texas Instruments XDS100v2 USB Debug
Probe_0/C28xx_CPU2”. As before, then run the code on CPU2 by clicking the “Resume”
button. LED D9 should now also be blinking, though at a different frequency than D10.
28. Halt the CPU2 program by clicking on the “Suspend” button. In the Expressions window the
ToggleCount2 variable should have recorded a small number of LED state changes.
Notice that the ToggleCount1 variable is not recognized on CPU2
29. Click on CPU1 in the Debug window and halt the program using the “Suspend” button.
Again, the ToggleCount1 variable should have a small number while ToggleCount2 is
unrecognized.
In the forthcoming labs we will explore several other features of the CCS environment, including
real-time debugging and the graph plotting capabilities of the software.
End of Exercise
Boot Process
Dual-Core Boot Process
CPU1 starts execution from CPU1 boot
ROM while CPU2 is held in reset
CPU1 controls the boot process
Reset – Bootloader
Reset vector
Reset fetched from
ENPIE = 0 boot ROM CPU2 held in
INTM = 1 reset until
0x3F FFC0 released by
CPU1.
CPU2
YES Emulator NO
Emulator Connected
Emulation Boot If either EMU_KEY or EMU_BMODE
are invalid, the “wait” boot mode is
Boot determined by used. These values can then be
EMU_BOOTCTRL : modified using the debugger and a
EMU_KEY and EMU_BMODE reset issued to restart the boot process.
NO Boot Mode
EMU_KEY = 0x5A ?
Wait
YES
GPIO 72 GPIO 84 Boot Mode
EMU_BMODE = 0xFE ? YES 0 0 Parallel I/O Boot pins can be
0 1 SCI-A mapped to any GPIO
CPU1 only pins. GetMode reads
1 0 Wait ZxOTP_BOOTCTRL
NO 1 1 GetMode (not the boot pins).
Continued from
previous slide NO Boot Mode
OTP_KEY = 0x5A ?
EMU_BMODE = Boot Mode FLASH
0x00 Parallel I/O YES
0x01 SCI-A OTP_BMODE = Boot Mode
0x03 GetMode 0x00 Parallel I/O
CPU1 0x04 SPI-A 0x01 SCI-A
& 0x05 I2C-A 0x04 SPI-A
CPU2 0x07 CAN-A 0x05 I2C-A
0x0A M0 SARAM 0x07 CAN-A
0x0B FLASH 0x0A M0 SARAM
other Wait CPU1
0x0B FLASH GetMode
0x0C USB-0 0x0C USB-0
0x81 SCI-A * other Wait
CPU1
only 0x84 SPI-A * 0x81 SCI-A *
0x85 I2C-A * 0x84 SPI-A *
0x87 CAN-A * 0x85 I2C-A *
* Alternate RX/TX GPIO 0x87 CAN-A *
pin mapping for CPU1 only OTP_BMODE = Boot Mode
0x0B FLASH CPU2
other Wait GetMode
0x080000 0x080000
FLASH (512Kw)
Interrupt Sources
Interrupt Sources
Internal Sources
TINT2
TINT1 F28x CORE
TINT0 XRS
NMI
ePWM, eCAP, eQEP,
PIE INT1
ADC, SCI, SPI, I2C,
(Peripheral
eCAN, McBSP, INT2
Interrupt
DMA, CLA, WD
Expansion) INT3
•
•
•
External Sources
INT12
INT13
XINT1 – XINT5
INT14
TZx
XRS
INT1 1
INT2 0 F28x
Core
INT14 1
INTM
INT10.y interrupt group 28x
IER
IFR
12 Interrupts
INT11.y interrupt group Core
INT13 (TINT1)
INT14 (TINT2)
NMI
INT4
INT7
INT8 UPPA
INT9 USBA
ADCD_ ADCC_
INT10 ADCD4 ADCD3 ADCD2 EVT ADCC4 ADCC3 ADCC2 EVT
INT11
AUX_PLL SYS_PLL RAM_ACC FLASH_C RAM_C_ EMIF_
INT12 CLA_UF CLA_OF _SLIP _SLIP _VIOLAT _ERROR ERROR ERROR
PIE Registers
PIEIFRx register (x = 1 to 12)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
INTx.16 INTx.15 INTx.14 INTx.13 INTx.12 INTx.11 INTx.10 INTx.9 INTx.8 INTx.7 INTx.6 INTx.5 INTx.4 INTx.3 INTx.2 INTx.1
PIECTRL register 15 - 1 0
PIEVECT ENPIE
#include “F2837x_Device.h”
PieCtrlRegs.PIEIFR1.bit.INTx4 = 1; //manually set IFR for XINT1 in PIE group 1
PieCtrlRegs.PIEIER3.bit.INTx2 = 1; //enable PWM2 interrupt in PIE group 3
PieCtrlRegs.PIEACK.all = 0x0004; //acknowledge the PIE group 3
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //enable the PIE
•
•
•
• •
• • Boot ROM
// Core INT1 re-map •
• // Enable PIE Block Reset Vector
• PieCtrlRegs.
•
// Core INT12 re-map PIECTRL.bit.
ENPIE=1;
3
CodeStartBranch.asm
.sect “codestart”
_c_int00: rts2800_fpu32.lib
• Interrupt
•
•
CALL main()
PIE Vector Table
CPU2 CORE
NMI
INT1
ePIE.2 INT2
INT3
•
•
•
Internal Sources INT12
TINT0.2 DMA1.2 CLA1.2 INT13
TINT1.2 INT14
TINT2.2
Internal 1x SYSCLKDIV
OSC2CLK OSCCLK
OSC 2 00* 0*
(10 MHz) (PLL bypass)
01
MUX
1/n PLLSYSCLK
XCLKIN X1
XTAL OSC
(X2 n.c.) PLLCLK
PLL 1
XTAL
EXTCLK
SYSPLLCTL1
XCLKOUTSEL SYSPLLMULT
X2
XCLKOUTDIV
110
101
AUXPLLCLK 101
CPU2.SYSCLK 011 1/n XCLKOUT
CPU1.SYSCLK 010 (GPIO 73)
PLLCLK 001
PLLSYSCLK 000*
AUXOSCCLKSRCSEL
AUXPLLDIV
PLLSYSCLK CPUx.SYSCLK
1/n CPUx
PLLCLK LOSPCP CPUx.LSPCLK
PLL 1
ClkCfgRegs.SYSPLLCTL1.bit.PLLCLKEN
ClkCfgRegs.SYSPLLMULT.bit.IMULT ClkCfgRegs.LOSPCP.bit.LSPCLK
ClkCfgRegs.SYSPLLMULT.bit.FMULT
PERx.SYSCLK PERx.SYSCLK
PERx CPUSELy
/1, /2 PERx SCIx SPIx
EPWMCLK
PERCLKDIVSEL
EPWM
CPU2.TMR2CLKCTL
EPWMCLKDIV CPU2.SYSCLK
INTOSC1
WD.2 INTOSC2
EXTCLK CPUTIMER2.2
WDCLK AUXPLLCLK
WD.1
CPU1.SYSCLK
INTOSC1 CPUTIMER2.1
PERx.SYSCLK INTOSC2
CANx Bit CLK
EXTCLK EXTCLK
AUXCLKIN AUXPLLCLK
CANxBCLKSEL CPU1.TMR2CLKCTL
WDCLK /512
Watchdog
Prescaler WDDIS
WDCNTR
8-bit Watchdog
Counter
CLR CNT
WDRST
System Output
Reset Pulse
WDWCR WDCNTR
less than WDINT
window WDWCR
55 + AA
Detector minimum
Good Key
WDCHK
Watchdog
Reset Key
Register 3
/
/ Bad WDCHK Key
WDKEY 3
1 0 1
GPIO Port A
[GPIO 0 to 15] [GPIO 0 to 15]
Direction Register
(GPADIR)
GPIO Port A Group GPIO Port A Mux2 [GPIO 0 to 31]
Mux2 Register Register
(GPAGMUX2) (GPAMUX2)
[GPIO 16 to 31] [GPIO 16 to 31]
Internal Bus
GPIO Port F
[GPIO 160 to 175] [GPIO 160 to 175]
Direction Register
(GPFDIR)
GPIO Port F Group GPIO Port F Mux2 [GPIO 160 to 191]
Mux2 Register Register
(GPFGMUX2) (GPFMUX2)
[GPIO 176 to 191] [GPIO 176 to 191]
Peripheral 13
Peripheral 14
12 ••
Internal Pull-Up • 01 10 11•
00
Peripheral 15
GPxPUD 0 = enable
1 = disable
Pin (default GPIO 0-xx) GPxMUX1/2
See device datasheet for pin function selection matrices Output X-Bar muxed with Peripheral GPIO pins
Logic shown is functional representation, not actual implementation * = Default x = A, B, C, D, E, or F
CPUx.SYSCLK
T T T
T = qual period
TZ1, TRIP1
XINT5
TZ2, TRIP2
CPU.PIE XINT4
TZ3, TRIP3
XINT3
CLA XINT2 TRIP4
XINT1 TRIP5
TRIP7 ePWM
ePWM TRIP8
Modules
X-Bar TRIP9
TRIP10
TRIP11
TRIP12
TRIP6
ADC ADCEXTSOC
EXTSYNCIN1 ePWM and eCAP
EXTSYNCIN2 Sync Chain
Output X-Bar
GPIO 0
INPUTx
GPIO n
INPUTxSELECT
Input Destinations
INPUT1 ePWM[TZ1, TRIP1], ePWM X-Bar, Output X-Bar
INPUT2 ePWM[TZ2, TRIP2], ePWM X-Bar, Output X-Bar
INPUT3 ePWM[TZ3, TRIP3], ePWM X-Bar, Output X-Bar
INPUT4 XINT1, ePWM X-Bar, Output X-Bar
INPUT5 XINT2, ADCEXTSOC, EXTSYNCIN1, ePWM X-Bar, Output X-Bar
INPUT6 XINT3, ePWM[TRIP6], EXTSYNCIN2, ePWM X-Bar, Output X-Bar
INPUT7 eCAP1
INPUT8 eCAP2
INPUT9 eCAP3
INPUT10 eCAP4
INPUT11 eCAP5
INPUT12 eCAP6
INPUT13 XINT4
INPUT14 XINT5
ECAP2 ECAP2.OUT
ECAP3 ECAP3.OUT SD2
FLT4.COMPH
ECAP4 ECAP4.OUT
FLT4.COMPL
ECAP5 ECAP5.OUT
ECAP6 ECAP6.OUT
31.1
31.2 This block diagram is replicated 8 times
31.3 31
31.4
OUTPUTxMUX16TO31CFG.MUX31
MUX 0 1 2 3 MUX 0 1 2 3
0 CMPSS1.CTRIPOUTH CMPSS1.CTRIPH_OR_CTRIPL ADCAEVT1 ECAP1.OUT 16 SD1FLT1.COMPH SD1FLT1.COMPH_OR_COMPL
1 CMPSS1.CTRIPOUTL INPUTXBAR1 ADCCEVT1 17 SD1FLT1.COMPL
2 CMPSS2.CTRIPOUTH CMPSS2.CTRIPH_OR_CTRIPL ADCAEVT2 ECAP2.OUT 18 SD1FLT2.COMPH SD1FLT2.COMPH_OR_COMPL
3 CMPSS2.CTRIPOUTL INPUTXBAR2 ADCCEVT2 19 SD1FLT2.COMPL
4 CMPSS3.CTRIPOUTH CMPSS3.CTRIPH_OR_CTRIPL ADCAEVT3 ECAP3.OUT 20 SD1FLT3.COMPH SD1FLT3.COMPH_OR_COMPL
5 CMPSS3.CTRIPOUTL INPUTXBAR3 ADCCEVT3 21 SD1FLT3.COMPL
6 CMPSS4.CTRIPOUTH CMPSS4.CTRIPH_OR_CTRIPL ADCAEVT4 ECAP4.OUT 22 SD1FLT4.COMPH SD1FLT4.COMPH_OR_COMPL
7 CMPSS4.CTRIPOUTL INPUTXBAR4 ADCCEVT4 23 SD1FLT4.COMPL
8 CMPSS5.CTRIPOUTH CMPSS5.CTRIPH_OR_CTRIPL ADCBEVT1 ECAP5.OUT 24 SD2FLT1.COMPH SD2FLT1.COMPH_OR_COMPL
9 CMPSS5.CTRIPOUTL INPUTXBAR5 ADCDEVT1 25 SD2FLT1.COMPL
10 CMPSS6.CTRIPOUTH CMPSS6.CTRIPH_OR_CTRIPL ADCBEVT2 ECAP6.OUT 26 SD2FLT2.COMPH SD2FLT2.COMPH_OR_COMPL
11 CMPSS6.CTRIPOUTL INPUTXBAR6 ADCDEVT2 27 SD2FLT2.COMPL
12 CMPSS7.CTRIPOUTH CMPSS7.CTRIPH_OR_CTRIPL ADCBEVT3 28 SD2FLT3.COMPH SD2FLT3.COMPH_OR_COMPL
13 CMPSS7.CTRIPOUTL ADCSOCA ADCDEVT3 29 SD2FLT3.COMPL
14 CMPSS8.CTRIPOUTH CMPSS8.CTRIPH_OR_CTRIPL ADCBEVT4 EXTSYNCOUT 30 SD2FLT4.COMPH SD2FLT4.COMPH_OR_COMPL
15 CMPSS8.CTRIPOUTL ADCSOCB ADCDEVT4 31 SD2FLT4.COMPL
Analog Subsystem
Analog Subsystem
Four dual-mode ADCs
16-bit mode
1 MSPS each (up to 4 MSPS system)
Differential inputs
External reference
12-bit mode
3.5 MSPS each (up to 14 MSPS system)
Single-ended or differential inputs
Internal or external reference
ADC Subsystem
ADC Subsystem
VREFA VREFC
DACOUTA/ADCINA0 0 Reserved 0
DACOUTB/ADCINA1 1 Reserved 1
CMPIN1P/ADCINA2 2 CMPIN6P/ADCINC2 2
CMPIN1N/ADCINA3 3 CMPIN6N/ADCINC3 3
CMPIN2P/ADCINA4 4 CMPIN5P/ADCINC4 4
CMPIN2N/ADCINA5 5 CMPIN5N/ADCINC5 5
Reserved 6 Reserved 6
Reserved 7
ADC-A Reserved 7
ADC-C
VREFLOA 8 16/12-bit VREFLOC 8 16/12-bit
VREFLOA 9 16 channel VREFLOC 9 16 channel
Reserved 10 Reserved 10
Reserved 11 Reserved 11
DACOUTA 12 DACOUTA 12
TEMP SENSOR 13 Reserved 13
14 14
CMPIN4P/ADCIN14
15 15
CMPIN4N/ADCIN15
VREFB VREFD
VDAC/ADCINB0 0 CMPIN7P/ADCIND0 0
DACOUTC/ADCINB1 1 CMPIN7N/ADCIND1 1
CMPIN3P/ADCINB2 2 CMPIN8P/ADCIND2 2
CMPIN3N/ADCINB3 3 CMPIN8N/ADCIND3 3
ADCINB4 4 ADCIND4 4
ADCINB5 5 ADCIND5 5
Reserved 6 Reserved 6
Reserved 7
ADC-B Reserved 7
ADC-D
VREFLOB 8 16/12-bit VREFLOD 8 16/12-bit
VREFLOB 9 16 channel VREFLOD 9 16 channel
Reserved 10 Reserved 10
Reserved 11 Reserved 11
DACOUTA 12 DACOUTA 12
Reserved 13 Reserved 13
14 14
15 15
*** Multiple ADC modules allow simultaneous sampling or independent operation ***
SOCx Triggers
SOC1 TRIGSEL CHSEL ACQPS
SOC2 TRIGSEL CHSEL ACQPS Software
SOC3 TRIGSEL CHSEL ACQPS CPU1 Timer (0,1,2)
EPWMxSOCA/C (x = 1 to 12)
EPWMxSOCB/D (x = 1 to 12)
External Pin(GPIO/ADCEXTSOC)
SOC15 TRIGSEL CHSEL ACQPS CPU2 Timer (0,1,2)
SOCx Configuration Registers
Software Trigger
TINT0 (CPU1 Timer 0) ADCSOCxCTL
TINT1 (CPU1 Timer 1)
TINT2 (CPU1 Timer 2)
T ADCRESULTx
ADCEXTSOC (GPIO) r
ADCINT1
SOCA/C (ePWM1) i
Channel Sample Result ADCINT2
SOCB/D (ePWM1) g
g S Select Window Register E ADCINT3
O O ADCINT4
e
SOCA/C (ePWM12) C C
r x x
SOCB/D (ePWM12)
TINT0 (CPU2 Timer 0)
TINT1 (CPU2 Timer 1)
ADCINTSOCSEL1
TINT2 (CPU2 Timer 2) INTSELxNy
ADCINTSOCSEL2
ADCINT1
ADCINT2
Re-Trigger
ADC Triggering
Example – ADC Triggering
Sample A0 A2 A5 when ePWM1 SOCB/D is generated and then generate ADCINT1:
SOCB/D (ETPWM1)
SOC0 Channel Sample Result0 no interrupt
A0 7 cycles
SOC1 Channel Sample
A2 10 cycles Result1 no interrupt
Software Trigger
SOC0
SOC1 SOC Priority
SOC2 Determines cutoff point
SOC3 for high priority and
round robin mode
SOC4
SOCPRIORITY
SOC5
SOC6 AdcRegs.SOCPRICTL
SOC7
Round Robin
SOC8 RRPOINTER
SOC9
SOC10 Round Robin Pointer
SOC11 Points to the last converted
SOC12 round robin SOCx and
SOC13 determines order
of conversions
SOC14
SOC15
BURSTSIZE
SOC Burst Size
Determines how many
BURSTTRIGSEL SOCs are converted per
burst trigger
FREECOUNT
+ EVENTx
ADCEVTSTAT.PPBxTRIPHI
ADCEVTSTAT.PPBxZERO
Offset Correction
w/ Saturation
ADCPPBxOFFCAL Threshold Compare
Zero
ADC Output + - saturate
Crossing
Σ ADCRESULTy
Detect
ADCPPBxTRIPHI + INTx
Error/Bipolar Calculation
-
+ Twos
-
ADCPPBxOFFREF Σ Comp ADCPPBxRESULT
Inv +
Enable
ADCPPBxCONFIG.TWOSCOMPEN ADCPPBxTRIPLO -
ADCEVTINTSEL.PPBxZERO
ADCEVTINTSEL.PPBxTRIPHI
ADCEVTINTSEL.PPBxTRIPLO
ADCEVTINT
Post Processing Block 3
EVENTx ADCEVT3
INTx
Comparator Subsystem
Comparator Subsystem
Eight Comparator
Subsystems (CMPSS)
Each CMPSS has: CMPIN1P/ADCINA2
CMPIN1N/ADCINA3
2
3
CMPIN2P/ADCINA4 4
Two analog comparators CMPIN2N/ADCINA5 5 ADC-A
CMPIN4P/ADCIN14 14
Two programmable 12-bit CMPIN4N/ADCIN15 15
DACs CMPIN3P/ADCINB2 2
CMPIN3N/ADCINB3 3 ADC-B
Two digital filters
Ramp generator CMPIN6P/ADCINC2
CMPIN6N/ADCINC3
2
3
CMPIN5P/ADCINC4 4 ADC-C
Digital filter used to CMPIN5N/ADCINC5 5
COMPH 0 Digital
1
DACH - 1 Filter
0 0
VALS DACH 12-bit
VALA DAC CTRIPOUTH ePWM
1 COMPHINV Event
COMPHSOURCE Trigger
DACSOURCE &
GPIO
+ CTRIPL
MUX
CMPINxN
COMPL 0 Digital
1
- 1 Filter
0
DACL DACL 12-bit
VALS VALA DAC CTRIPOUTL
COMPLINV
COMPLSOURCE
Digital-to-Analog Converter
Digital-to-Analog Converter
DACOUTA/ADCINA0 0
DACOUTB/ADCINA1 1
Provides a programmable
reference output voltage DACOUTC/ADCINB1 1
ADC-B
DACOUTA 12
Capable of driving an
external load
ADC-C
Ability to be synchronized DACOUTA 12
VDAC 0
VREFHI 1
VDDA DACOUTEN
VSSA 0
VREFLO 1
DACREFSEL
Ideal Output
DACVALA * DACREF VREFHIA can supply reference
VDACOUT = for DAC A and DAC B; VREFHIB
4096 can supply reference for DAC C
ΣΔ
Clk_out
Filter Module 1
Streams Direct
SDINT
Comparator R
Interrupt PIE
IN1 Filter Unit
CLK1 Input
Ctrl FILRES
R
Sinc Filter
Sync
IN2
Filter Module 2
CLK2
IN3
Sync Register VBUS32
Sync
IN4
Filter Module 4
CLK4
In order to generate an interesting input signal, the code also alternately toggles a GPIO pin high
and low in the ADC interrupt service routine. This pin will be connected to the ADC input pin by
means of a jumper wire. Using Code Composer Studio the sampled data will be viewed in
memory and displayed with the graphing feature. We will then configure one of the internal DACs
to generate a fixed frequency sine wave with programmable offset and measure this signal in the
same way.
ADCINA0
...
ePWM2 triggering
ADC on period match
using SOCA trigger every
20 µs (50 kHz) View ADC
buffer PWM
Samples
Code Composer
Studio
ePWM2
Procedure
Also, the ISR contains code to toggle the GPIO18 pin which be measured with the ADC. This
pin toggles between 0V and +3.3V every sixteen interrupts. If everything works as expected,
the AdcaResults buffer should contain a repeating sequence of 16 readings of close to
0x0000 followed by another 16 readings close to 0x0FFF (i.e. full scale).
The last two lines in the ISR clear the interrupt flag at the ADC and acknowledge the PIE
level group interrupt so that the next ADC EOC event will trigger an interrupt.
17. Run the code and watch the windows update in real-time mode. Click:
Scripts Realtime Emulation Control Run_Realtime_with_Reset
18. Carefully remove and replace the connector wire from the ADC input. Are the values
updating as expected? The ADC results should be zero when the jumper wire is removed.
The variable dacOffset allows the user to adjust the DC output from DAC-B from an
Expressions window in CCS. The variable sineEnable is a switch which adds a fixed
frequency sine wave to the DAC offset. The sine wave is generated using a 32-point look-up
table contained in the source file sinetab.c. We will plot the sine wave in a graph window
while manually adjusting the offset.
21. Open and inspect sinetab.c. (If needed, open the Project Explorer window in the “CCS
Debug” perspective view by clicking View Project Explorer). The file consists of an
array of 40 signed integer points which represent five quadrants of sinusoidal data. The first
32 points are a complete cycle. In the source code we need to sequentially access each of
the first 32 points in the array, converting each one from signed 16-bit to un-signed 12-bit
format before writing it to the DACVALS register of DAC-B.
22. In the Expressions window collapse the AdcaResults buffer variable by clicking on the “-“
symbol to the left of the variable name. Then add the following variables to the Expressions
window:
• sineEnable
• dacOffset
23. Remove the jumper wire from connector J1, pin #4 (GPIO18) and connect it to connector J7,
pin #70 (DACOUTB). Refer to the following diagram for the pins that need to be connected
using the jumper wire.
24. Run the code (real-time mode) using the Script function: Scripts Realtime
Emulation Control Run_Realtime_with_Reset
25. At this point the graph should be displaying a DC signal near zero. Click on the dacOffset
variable in the Expressions window and change the value to 800. This changes the DC
output of the DAC which is applied to the ADC input. The level of the graph display should
be about 800 and this should be reflected in the value shown in the memory buffer (note: 800
decimal = 0x320 hex).
26. Enable the sine generator by changing the variable sineEnable in the Expressions window
to 1.
27. You should now see sinusoidal data in the graph window.
28. Try removing and re-connecting the jumper wire to show this is real data is running in real-
time emulation mode. Also, you can try changing the DC offset variable to move the input
waveform to a different average value (the maximum distortion free offset is about 2000).
29. Fully halt the code (real-time mode) by using the Script function: Scripts Realtime
Emulation Control Full_Halt
End of Exercise
Control Peripherals
ePWM Module Signals and Connections
ePWM Module Signals and Connections
ePWMx-1
EPWMxSYNCI EPWMxTZINT
INPUT PIE
EPWMxINT
X-Bar CLA
EQEPERR – TZ4 EPWMxA
eQEP
GPIO
CLOCKFAIL – TZ5 ePWMx EPWMxB
SYSCTRL MUX
EMUSTOP – TZ6
CPU
EPWMxSOCA
ePWM EPWMxSOCB ADC
X-Bar EPWMxSYNCO
ePWMx+1
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Chopper Zone
EPWMxB
TZy
TZ1-TZ3
Digital
INPUT X-Bar
Compare ePWM X-Bar
TBPRD
Asymmetrical
Waveform
Count Up Mode
TBCTR
TBPRD
Asymmetrical
Waveform
TBPRD
Symmetrical
Waveform
Phase
φ=0°
En
o o .
SyncIn
EPWM1A
o
CTR=zero o
CTR=CMPB * o o EPWM1B
X o
SyncOut
To eCAP1
SyncIn
Phase
φ=120°
En
o o .
SyncIn
EPWM2A φ=120°
o
CTR=zero o
CTR=CMPB * o o EPWM2B
X o
SyncOut
Phase
φ=240°
En
o o .
SyncIn
EPWM3A
φ=120°
o
CTR=zero o
CTR=CMPB * o o EPWM3B
X o
SyncOut φ=240°
Count Up Mode
TBCTR
TBPRD .. .. ..
. .. .. ..
CMPA Asymmetrical
CMPB Waveform
.. ..
TBCTR
TBPRD
. .
.. ... ..
CMPA Symmetrical
CMPB Waveform
SW Z CA CB P T1 T2 Do Nothing
X X X X X X X
SW Z CA CB P T1 T2
Clear Low
↓ ↓ ↓ ↓ ↓ ↓ ↓
SW Z CA CB P T1 T2
Set High
↑ ↑ ↑ ↑ ↑ ↑ ↑
SW Z CA CB P T1 T2
Toggle
T T T T T T T
Tx Event Sources = DCAEVT1, DCAEVT2, DCBEVT1, DCBEVT2, TZ1, TZ2, TZ3, EPWMxSYNCIN
TBCTR
. .
TBPRD
. .
. .
CMPA
. . .
CMPB
Z P CB CA Z P CB CA Z P
↑ X X ↓ ↑ X X ↓ ↑ X
EPWMA
Z P CB CA Z P CB CA Z P
↑ X ↓ X ↑ X ↓ X ↑ X
EPWMB
TBCTR
. .
TBPRD
. .
. .
CMPB
. . .
CMPA
CA CB CA CB
↑ ↓ ↑ ↓
EPWMA
Z Z Z
T T T
EPWMB
TBPRD
... ...
CMPB
. . . .
. .
CMPA
.
CA CA CA CA
↑ ↓ ↑ ↓
EPWMA
CB CB CB CB
↑ ↓ ↑ ↓
EPWMB
TBPRD .. ..
CMPB
. .
. .
CMPA
.
CA CB CA CB
↑ ↓ ↑ ↓
EPWMA
Z P Z P
↓ ↑ ↓ ↑
EPWMB
supply rail
.
Rising
Edge
0 Delay
° S4° In Out
0
.
°1
0
° S1° 0
° S6°
(14-bit ° S2° RED PWMxA
°1
°
counter)
°1 °1
0
° °
.
DEDB-
MODE °
S8 1 0
° S7° PWMxB
.
0
1 S8 ° ° S3 FED 1
° S0° °1
. °
Falling
0
° ° S5 ° ° Edge °1
°0 Delay °0
°1 In Out
OUTSWAP
POLSEL OUT-MODE
(14-bit
IN-MODE counter)
.
PWMxB
HALFCYCLE
EPWMxB
CHPFREQ
EPWMxA
EPWMxB
Programmable
Pulse Width
OSHT (OSHTWTH)
Sustaining
EPWMxA Pulses
ePWM X-Bar
CTRIPOUTH TRIPIN4
CMPSS1 CTRIPOUTL TRIPIN5
TRIPIN7
All
TRIPIN8
TRIPIN9 ePWM
TRIPIN10
CTRIPOUTH TRIPIN11 Modules
CMPSS8 TRIPIN12
CTRIPOUTL
INPUT1
INPUT2
INPUT3
EPWM/ECAP sync EXTSYNCOUT INPUT4
INPUT X-Bar
INPUT5
INPUT6
ADCSOCAO ADCSOCA
FLT1.COMPH
ePWM
ADCSOCB FLT1.COMPL
ADCSOCBO
X-Bar
ADCA EVT1 to EVT4 SD1
FLT4.COMPH
ADCB EVT1 to EVT4
FLT4.COMPL
ADCC EVT1 to EVT4
ADCD EVT1 to EVT4
FLT1.COMPH
ECAP1 ECAP1.OUT FLT1.COMPL
ECAP2 ECAP2.OUT
ECAP3 ECAP3.OUT SD2
FLT4.COMPH
ECAP4 ECAP4.OUT
FLT4.COMPL
ECAP5 ECAP5.OUT
ECAP6 ECAP6.OUT
31.1
31.2 This block diagram is replicated 8 times
31.3 31
31.4
TRIPxMUX16TO31CFG.MUX31
MUX 0 1 2 3 MUX 0 1 2 3
0 CMPSS1.CTRIPOUTH CMPSS1.CTRIPH_OR_CTRIPL ADCAEVT1 ECAP1.OUT 16 SD1FLT1.COMPH SD1FLT1.COMPH_OR_COMPL
1 CMPSS1.CTRIPOUTL INPUTXBAR1 ADCCEVT1 17 SD1FLT1.COMPL
2 CMPSS2.CTRIPOUTH CMPSS2.CTRIPH_OR_CTRIPL ADCAEVT2 ECAP2.OUT 18 SD1FLT2.COMPH SD1FLT2.COMPH_OR_COMPL
3 CMPSS2.CTRIPOUTL INPUTXBAR2 ADCCEVT2 19 SD1FLT2.COMPL
4 CMPSS3.CTRIPOUTH CMPSS3.CTRIPH_OR_CTRIPL ADCAEVT3 ECAP3.OUT 20 SD1FLT3.COMPH SD1FLT3.COMPH_OR_COMPL
5 CMPSS3.CTRIPOUTL INPUTXBAR3 ADCCEVT3 21 SD1FLT3.COMPL
6 CMPSS4.CTRIPOUTH CMPSS4.CTRIPH_OR_CTRIPL ADCAEVT4 ECAP4.OUT 22 SD1FLT4.COMPH SD1FLT4.COMPH_OR_COMPL
7 CMPSS4.CTRIPOUTL INPUTXBAR4 ADCCEVT4 23 SD1FLT4.COMPL
8 CMPSS5.CTRIPOUTH CMPSS5.CTRIPH_OR_CTRIPL ADCBEVT1 ECAP5.OUT 24 SD2FLT1.COMPH SD2FLT1.COMPH_OR_COMPL
9 CMPSS5.CTRIPOUTL INPUTXBAR5 ADCDEVT1 25 SD2FLT1.COMPL
10 CMPSS6.CTRIPOUTH CMPSS6.CTRIPH_OR_CTRIPL ADCBEVT2 ECAP6.OUT 26 SD2FLT2.COMPH SD2FLT2.COMPH_OR_COMPL
11 CMPSS6.CTRIPOUTL INPUTXBAR6 ADCDEVT2 27 SD2FLT2.COMPL
12 CMPSS7.CTRIPOUTH CMPSS7.CTRIPH_OR_CTRIPL ADCBEVT3 28 SD2FLT3.COMPH SD2FLT3.COMPH_OR_COMPL
13 CMPSS7.CTRIPOUTL ADCSOCA ADCDEVT3 29 SD2FLT3.COMPL
14 CMPSS8.CTRIPOUTH CMPSS8.CTRIPH_OR_CTRIPL ADCBEVT4 EXTSYNCOUT 30 SD2FLT4.COMPH SD2FLT4.COMPH_OR_COMPL
15 CMPSS8.CTRIPOUTL ADCSOCB ADCDEVT4 31 SD2FLT4.COMPL
Trip-Zone Features
Trip-Zone has a fast, clock independent logic path to high-impedance
the EPWMxA/B output pins
Interrupt latency may not protect hardware when responding to over
current conditions or short-circuits through ISR software
Supports: #1) one-shot trip for major short circuits or over
current conditions
#2) cycle-by-cycle trip for current limiting operation
Over
Current CPU
Sensors core P
Digital EPWMxA W
Compare M
EPWMxTZINT
Cycle-by-Cycle O
INPUT X-Bar U
ePWM X-Bar Mode T
TZ4 EQEP1ERR P
eQEP1 EPWMxB U
TZ5 CLOCKFAIL One-Shot
SYSCTRL T
CPU TZ6 EMUSTOP Mode S
●
Time-Base Sub-Module
● DCBEVT1
DCBH Digital Trip Generate PWM Sync
TRIPIN12 Event B1
Compare Event-Trigger Sub-Module
TRIPIN14
Generate SOCB
TRIPIN15 blanking
Digital Trip Trip-Zone Sub-Module
TRIP COMBO DCBL
Event B2 Trip PWMB Output
Compare
Generate Trip Interrupt
DCBEVT2
DCTRIPSEL TZDCSEL DCACTL / DCBCTL
. .. . ..
. . . .
TBPRD
. .. .. ..
CMPD
.
CMPC
. . .
CMPB
CMPA
CTR = 0
CTR = PRD
CTR = 0 or PRD
CTRU = CMPA
CTRD = CMPA
CTRU = CMPB
CTRD = CMPB
CTRU = CMPC
CTRD = CMPC
CTRU = CMPD
CTRD = CMPD
Regular
Device Clock PWM Step
(i.e. 100 MHz) (i.e. 10 ns)
(fixed Time-Base/2)
HRPWM
Micro Step (~150 ps)
Timer
Trigger
pin
Timestamp
Values
CAP2POL
Capture 2 Polarity
Event Logic
Register Select 2 PRESCALE
32-Bit Event
Time-Stamp Prescale
Counter CAP3POL ECAPx
Capture 3 Polarity pin
CPUx.SYSCLK Register Select 3
CAP4POL
Capture 4 Polarity
Register Select 4
Shadowed
Period
shadow
Period Register mode
immediate Register (CAP3)
mode
(CAP1)
32-Bit PWM
Time-Stamp Compare
Counter Logic ECAP
pin
CPUx.SYSCLK
Compare
immediate
mode Register Compare
shadow
(CAP2) Register mode
Shadowed (CAP4)
Ch. A
Ch. B
shaft rotation
(00) (11)
increment decrement
(A,B) = counter 10 counter
(10) (01)
Illegal
Ch. A Transitions;
00 generate 11
phase error
interrupt
Ch. B
01
Quadrature Decoder
State Machine
Position/Counter
Compare
Generate the direction and
clock for the position counter
Generate a sync output in quadrature count mode
and/or interrupt on a
position compare match
Ch. A
Quadrature Ch. B
Capture
EQEPxA/XCLK
32-Bit Unit EQEPxB/XDIR
Time-Base
Quadrature
QEP Decoder EQEPxI Index
Watchdog
CPUx.SYSCLK EQEPxS Strobe
from homing sensor
Position/Counter
Compare
...
CPU copies
PWM5A results to
Phase buffers during
TB Counter ADC ISR
connector AdccResults
Compare wire ADCC
Action Qualifier
RESULT0
PWM1 period = programmable ADCC3
PWM1 duty = programmable
PWM5 period = synchronized
...
PWM5 duty = programmable
PWM5 phase = programmable
View both
PWM2 triggering ADC buffers
ADC on period match
using SOCA trigger every
20 µs (50 kHz) PWM2 Code Composer
Studio
Procedure
InitEPwm1()
InitEPwm2()
InitEPwm5()
The code for these functions is located further down in the same file.
3. Scroll down the file and locate the function InitEPwm1(). Inspect the code and notice the
following line:
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1;
This configures the TB module to generate a SYNC output on a CTR = 0 match. Notice also
the setting of the PHSEN bit in the same register. This bit disables the SYNC input to this
module.
4. Scroll further down the file and locate the function InitEPwm5(). Inspect the code and
notice the setting of the PHSEN bit in this module. This bit enables synchronization from the
SYNC input from EPWM1.
At the bottom of this function are the following lines used to configure the AQ module:
EPwm5Regs.AQCTLA.bit.ZRO = 2;
EPwm5Regs.AQCTLA.bit.CAU = 1;
These define a HIGH output on a CTR = zero event and a LOW output on a compare match
when counting UP. The result is an asynchronous PWM with trailing edge duty cycle
modulation. ePWM1 is configured in the same way.
5. At the bottom of the file is the ADC Interrupt Service Routine adca1_isr(). As in the
previous lab exercise, this interrupt is triggered by an end-of-conversion (EOC) event from
ADC-A. The ISR code reads and stores the newest ADCINA0 result in the buffer
AdcaResults and the newest ADCINC3 result in buffer AdccResults. Since ADC-A and
ADC-C are configured similarly, their conversion time will be the same and we only need one
ISR to collect both readings.
6. Notice the code near the bottom of the ISR which manipulates the variables pretrig and
trigger. The ISR code has been written so that the first sample in both buffers is taken on
a rising edge of PWM1A. When we view the results in a graph window, this makes it easier
to see the effects of changes to PWM duty cycle and phase offset.
16. The Expressions window should still be open from the previous lab exercise. If not, then click
the “Expressions” tab near the top of the CCS window. Add the following variables to the
Expressions window:
• period1
• dutyCycle1
• dutyCycle5
• phaseOffset5
The other expressions are not needed for this lab exercise and can safely be deleted from
the Expression list, if desired.
19. Run the code and watch the windows update in real-time mode. Click:
Scripts Realtime Emulation Control Run_Realtime_with_Reset
20. Carefully remove and replace the connector wire to the ADCINA0 input (connector J3, pin
#30). The ADC results graph A should be zero when the jumper wire is removed.
Next, carefully remove and replace the connector wire to the ADCINC3 input (connector J3,
pin #24). The ADC results graph B should be zero when the jumper wire is removed. This
confirms both buffers are updating in real-time.
23. Next, change the duty cycle variables dutyCycle1 and dutyCycle5 while observing the
PWM signals. In both cases be careful to choose a number between about 1000 and 49000.
Were the changes to the PWM signals as expected?
24. Now change the phaseOffset5 variable to a positive number between 0 and 49000. What
effect did this have?
25. Set the PWM variables as follows:
period1 = 50000
dutyCycle1 = 25000
dutyCycle5 = 25000
phaseOffset5 = 25000
What is the relationship between these PWM waveforms called?
26. Finally, set the variable period1 to 75000. What happened and why?
End of Exercise
* default
There are up to 16 blocks of shared SARAM on F2837xD devices. These shared SARAM blocks
are typically used by the application, but can also be used for transferring messages and data.
On the CPU2 core, CPU2 and CPU2.DMA can only read from these blocks. Blocks owned by the
CPU1 core can be used by the CPU1 to send CPU2 messages. This is referred to as “C1toC2”.
The F2837xD has two dedicated message RAM blocks. Each block is 1K words in length. Unlike
the shared SARAM blocks, these blocks provide communication in one direction only and cannot
be reconfigured.
When the sending CPU wishes to inform the receiver that a message is ready, it can make use of
an interrupt or flag. There are identical IPC interrupt and flag resources on both CPU1 core and
CPU2 core.
4 Interrupts:
There are 4 interrupts that CPU1 can send to CPU2 through the Peripheral Interrupt Expansion
(PIE) module. Each of the interrupts has a dedicated vector within the PIE.
28 Flags:
In addition, there are 28 flags available to each of the CPU cores. These flags can be used for
messages that are not time critical or they can be used to send status back to originating
processor. The flags and interrupts can be used however the application sees fit and are not tied
to particular operation in hardware.
CPU1 Memory Map IPC Registers CPU1 to CPU2 CPU2 Memory Map
PIE
Set Q
(IPC0-3)
IPCSET
Clear IPC Registers
IPCCLR IPCACK
R/W
CPU1 IPCFLG IPCSTS
R/W
IPCSTS IPCFLG CPU2
IPCACK IPCCLR
Clear
IPCSET
PIE
Q Set
(IPC0-3)
CPU2 to CPU1
C1TOC2IPCFLG C1TOC2IPCSTS
The F2837xD IPC is very easy to use. At the most basic level, the application does not need
ANY separate software drivers to communicate between processors. It can utilize the message
RAM’s and shared SARAM blocks to pass data between processors at a fixed address known to
both processors. Then the sending processor can use the IPC flag registers merely to flag to the
receiving processor that the data is ready. Once the receiving processor has grabbed the data, it
will then acknowledge the corresponding IPC flag to indicate that it is ready for more messages.
As an example:
1. First, CPU1 would write a message to the CPU2 in C1toC2 MSG RAM.
2. Then the CPU1 would write a 1 to the appropriate flag bit in the C1TOC2IPCSET
register. This sets the C1TOC2IPCFLG, which also sets the C1TOC2IPCSTS register on
CPU2, letting CPU2 know that a message is available.
3. Then CPU2 sees that a bit in the C1TOC2IPCSTS register is set.
4. Next CPU2 reads the message from the C1toC2 MSG RAM and then
5. It writes a 1 to the same bit in the C1TOC2IPCACK register to acknowledge that it has
received the message. This subsequently clears the flag bit in C1TOC2IPCFLG and
C1TOC2IPCSTS.
6. CPU1 can then send more messages using that particular flag bit.
Basic option: A very simple option that does not require any drivers. This option only requires
IPC registers to implement very simple flagging of messages passed between processors.
Driver options: If the application code needs a set of basic IPC driver functions for reading or
writing data, setting/clearing bits, and function calls, then there are 2 IPC software driver solutions
provided by TI.
IPC-Lite:
• Only uses the IPC registers. No additional memory such as message RAM or shared
RAM is needed.
• Only one IPC ISR can be used at a time.
• Can only process one message at a time.
• CPU1 can use IPC lite to communicate with the CPU2 boot ROM. The CPU2 boot ROM
processes basic IPC read, write, bit manipulation, function call, and branch commands.
Main IPC Software API Driver: (This is a more feature filled IPC solution)
• Utilizes circular buffers in C2toC1 and C1toC2 message RAM’s.
• Allows application to queue up to 4 messages prior to processing (configurable).
• Allows application to use multiple IPC ISR’s at a time.
• Requires additional set up in application code prior to use.
In addition to the above, SYS/BIOS 6 will provide a new transport module to work with the shared
memory and IPC resources on the F2837x.
DAC-B
IPCRECVADDR IPCSENDADDR
DACVALS IPC0
Pin 11
...
IPC1_ISR
1. Reads IPC1 data
connector and stores in circular
wire
ADCA1_ISR buffer
2. Writes next sine ADC Results
Reads ADC result and writes to IPC1
data to IPC0
ADC-A
IPCSENDDATA IPCRECVDATA
RESULT0 IPC1
Pin 09
Toggle GPIO34 D9 @ 1 Hz
...
Toggle GPIO31 D10 @ 5 Hz
View ADC
buffer
PWM2 triggers
ADC-A at 50 kHz
Code Composer
Studio
Procedure
11. Next, we need to connect to and load the program on CPU2. Right-click at the line “Texas
Instruments XDS100v2 USB Debug Probe_0/C28xx_CPU2” and select “Connect Target”.
12. With the line “Texas Instruments XDS100v2 USB Debug Probe_0/C28xx_CPU2” still
highlighted, load the program:
21. In the Debug window highlight the line “Texas Instruments XDS100v2 USB Debug
Probe_0/C28xx_CPU1”. Run the code on CPU1 in real-time mode by clicking:
22. Next, in the Debug window highlight the line “Texas Instruments XDS100v2 USB Debug
Probe_0/C28xx_CPU2”. Run the code on CPU2 in real-time mode by using the same
procedure above.
24. Again, in the Debug window highlight the line “Texas Instruments XDS100v2 USB Debug
Probe_0/C28xx_CPU1”. Fully halt the code on CPU1 in real-time mode by clicking:
Scripts Realtime Emulation Control Full_Halt
25. Next, fully halt the code on CPU2 in real-time mode by using the same procedure.
End of Exercise
Support Resources
C2000 MCU Multi-day Training Course
C2000 MCU Multi-day Training Course
TMS320F28379D Workshop Outline
- Architectural Overview
- Programming Development Environment
- Peripheral Register Header Files
- Reset and Interrupts
- System Initialization
- Analog Subsystem
- Control Peripherals
In-depth hands-on - Direct Memory Access (DMA)
TMS320F28379D - Control Law Accelerator (CLA)
Design and Peripheral - System Design
Training - Dual-Core Inter-Processor
Communications (IPC)
- Communications
- Support Resources
controlSUITE™
controlSUITE™
Experimenter’s Kit
C2000 Experimenter Kit
Experimenter Kits include
controlCARD
USB docking station
C2000 Applications Software CD
with example code and full
Part Number: hardware details
TMDSDOCK28379D
Code Composer Studio
TMDSDOCK28075
TMDSDOCK28069 Docking station features
TMDSDOCK28035 Access to controlCARD signals
TMDSDOCK28027
TMDSDOCK28335 Breadboard areas
TMDSDOCK2808 Onboard USB JTAG Emulation
TMDSDOCKH52C1 JTAG emulator not required
JTAG emulator required for: Available through TI authorized
TMDSDOCK28343
distributors and the TI store
TMDSDOCK28346-168
Application Kits
C2000 controlCARD Application Kits
Developer’s Kit for – Motor Control,
PFC, High Voltage, Digital Power,
Renewable Energy, LED Lighting, etc.
Kits includes
controlCARD and application specific
baseboard
Code Composer Studio
Software download includes
Complete schematics, BOM, gerber
files, and source code for board and
all software
Quick-start demonstration GUI for
quick and easy access to all board
features
Fully documented software specific to
each kit and application
See www.ti.com/c2000 for other kits
and more details
Available through TI authorized
distributors and the TI eStore
www.blackhawk-dsp.com www.spectrumdigital.com
http://www.ti.com/hands-on-training
Insert the F28379D controlCARD into the Docking Station connector slot. Using the two (2)
supplied USB cables – plug the USB Standard Type A connectors into the computer USB ports
and plug the USB Mini-B connectors as follows:
On the Docking Station move switch S1 to the “USB-ON” position. This will power the Docking
Station and controlCARD using the power supplied by the computer USB port. Additionally, the
other computer USB port will power the on-board isolated JTAG emulator and provide the JTAG
communication link between the device and Code Composer Studio.