C28 X 1 Day Workshop
C28 X 1 Day Workshop
C28 X 1 Day Workshop
F28xPodw
Revision 2.0
June 2010
Technical Training
Organization
Workshop Topics
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 2009 – Revision 1.0
October 2009 – Revision 1.1
June 2010 – Revision 2.0
Mailing Address
Texas Instruments
Training Technical Organization
7839 Churchill Way
M/S 3984
Dallas, Texas 75251-1903
Workshop Topics
Workshop Topics.........................................................................................................................................3
Workshop Introduction ...............................................................................................................................4
Architecture Overview ................................................................................................................................8
Programming Development Environment.................................................................................................10
Code Composer Studio.........................................................................................................................10
Linking Sections in Memory ................................................................................................................12
Lab 1: Linker Command File....................................................................................................................15
Peripheral Register Header Files .............................................................................................................21
Reset, Interrupts and System Initialization ...............................................................................................28
Reset .....................................................................................................................................................28
Interrupts ..............................................................................................................................................30
Peripheral Interrupt Expansion (PIE) ...................................................................................................32
Oscillator / PLL Clock Module ............................................................................................................34
Watchdog Timer Module......................................................................................................................35
GPIO.....................................................................................................................................................36
Lab 2: System Initialization ......................................................................................................................38
Control Peripherals ..................................................................................................................................43
ADC Module ........................................................................................................................................43
Pulse Width Modulation.......................................................................................................................45
ePWM...................................................................................................................................................46
eCAP ....................................................................................................................................................59
eQEP.....................................................................................................................................................60
Lab 3: Control Peripherals.......................................................................................................................62
Flash Programming ..................................................................................................................................68
Flash Programming Basics ...................................................................................................................68
Programming Utilities and CCS Flash Programmer.............................................................................69
Code Security Module and Password ...................................................................................................70
Lab 4: Programming the Flash.................................................................................................................72
The Next Step….........................................................................................................................................79
Training ................................................................................................................................................79
Development Tools...............................................................................................................................80
Development Support ...........................................................................................................................82
NOTES:.....................................................................................................................................................84
Workshop Introduction
C2000™ Piccolo™ 1-Day Workshop
Texas Instruments
Technical Training
T TO
Technical Training
Organization C2000 and Piccolo are trademarks of Texas Instruments. Copyright © 2010 Texas Instruments. All rights reserved.
Introductions
Name
Company
Project Responsibilities
DSP / Microcontroller Experience
TI Processor Experience
Hardware / Software - Assembly / C
Interests
C2834x
300 MIPS
Control Performance
F2833x/23x
150 MIPS
F281x
Multi-Function, 150 MIPS
Appliance & F280x/xx F2803x/2x
100 MIPS 60 MIPS
Consumer Control
F24xx
40 MIPS Cost
optimized
versions
Automotive
Radar, Electric
Power Steering Power Line
& Digital Power Communications
LED Lighting
Consumer,
Medical &
Non-traditional
For details and information on other C2000 family members refer to the “Embedded Proc essing Guide” and specific “Data Manuals”
Piccolo™ ControlSTICK
Architecture Overview
TMS320F2802x/3x Block Diagram
Program Bus
ePWM
Boot eCAP
Sectored RAM
ROM
Flash eQEP
CLA Bus
12-bit ADC
Watchdog
PIE
32-bit R-M-W Interrupt CAN 2.0B
32x32 bit Manager
Auxiliary Atomic CLA
Multiplier I2C
Registers ALU
3
Real-Time SCI
32-bit
JTAG Register Bus Timers SPI
Emulation CPU
LIN
Data Bus
GPIO
Available only on TMS320F2803x devices: CLA, QEP, CAN, LIN
CSM Protected:
L0, OTP
FLASH, ADC CAL,
Flash Regs in PF0
context save
Auto Context Save
T ST0
AH AL
PH PL
AR1 (L) AR0 (L)
DP ST1
DBSTAT IER
PC(msw) PC(lsw)
CCSv4 Project
List of files:
Source (C, assembly)
Libraries
DSP/BIOS configuration file
Linker command files
Project settings:
Build options (compiler,
Linker, assembler, and
DSP/BIOS)
Build configurations
Compiler Linker
16 categories for code 9 categories for linking
generation tools Specify various link
Controls many aspects of options
the build process, such as: ${PROJECT_ROOT}
Optimization level specifies the current
Target device
project directory
Compiler / assembly / link
options
Uninitialized Sections
Name Description Link Location
.ebss global and static variables RAM
.stack stack space low 64Kw RAM
.esysmem memory for far malloc functions RAM
Memory
Sections
0x00 0000 M0SARAM
(0x400)
.ebss
0x00 0400 M1SARAM
(0x400)
.stack
.text
Linking
z Memory description
z How to place s/w into h/w
Link.cmd
.map
Use a linker command file to link the C program file (Lab1.c) into the system described below.
System Description:
• TMS320F28027
• All internal RAM
blocks allocated
Placement of Sections:
• .text into RAM Block L0SARAM on PAGE 0 (program memory)
• .cinit into RAM Block L0SARAM on PAGE 0 (program memory)
• .ebss into RAM Block M0SARAM on PAGE 1 (data memory)
• .stack into RAM Block M1SARAM on PAGE 1 (data memory)
System Description
• TMS320F28027
• All internal RAM blocks allocated
Placement of Sections:
• .text into RAM Block L0SARAM on PAGE 0 (program memory)
• .cinit into RAM Block L0SARAM on PAGE 0 (program memory)
• .ebss into RAM Block M0SARAM on PAGE 1 (data memory)
• .stack into RAM Block M1SARAM on PAGE 1 (data memory)
¾ 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 a “Welcome to Code Composer Studio v4” page appears.
Close the page by clicking on the CCS icon in the upper right or by clicking the X on the
“Welcome” 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 “C/C++ Perspective” view. Notice the C/C++ 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 “C/C++ Perspective” is used to create or build C/C++ projects. A “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 F28027_ctrlSTK.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 XDS100v1 USB Emulator”. In the box
below, check the box to select “controlSTICK – Piccolo F28027”. Click
Save to save the configuration, then close the “Cheat Sheets” and
“F28027_ctrlSTK.ccxml” file by clicking the X on the tabs.
and click the plus sign (+) to the left of User Defined. Notice that the
F28027_ctrlSTK.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.
C:\C28x\Labs\Lab1\Project
7. The next window that appears selects the platform and configurations. Select the
“Project Type” using the pull-down list and choose “C2000”. In the “Configurations”
box below, leave the “Debug” and “Release” boxes checked. This will create folders that
will hold the output files. Click Next.
8. In the next window, inter-project dependencies (if any) are defined. Select Next.
9. In the last window, the CCS project settings are selected. Change the “Runtime Support
Library” using the pull-down list to “rts2800_ml.lib”. This will select the large
memory model runtime support library. Click Finish.
10. A new project has now been created. Notice the C/C++ Projects window contains
Lab1. 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.
11. To add the source files to the project, right-click on Lab1 in the C/C++ Projects
window and select:
Add Files to Project…
12. In the C/C++ Projects window, click the plus sign (+) to the left of Lab1 and notice
that the files are listed.
14. A “Properties” window will open and in the section on the left be sure that “C/C++
Build” category is selected. In the “Configuration Settings” section make sure that the
Tool Settings tab is selected. Next, under “C2000 Linker” select the “Basic
Options”. Notice that .out and .map files are being specified. The .out file is the
executable code that will be loaded into the MCU. The .map file will contain a linker
report showing memory usage and section addresses in memory.
15. Next in the “Basic Options” set the Stack Size to 0x200.
16. Under “C2000 Compiler” select the “Runtime Model Options”. Check the “Use
large memory model” box. Select OK to save and close the Properties window.
18. In the Sections{} area notice that the sections defined on the slide have been “linked”
into the appropriate memories. Also, notice that a section called .reset has been allocated.
The .reset section is part of the rts2800_ml.lib, and is not needed. By putting the TYPE =
DSECT modifier after its allocation, the linker will ignore this section and not allocate it.
Close the inspected file.
20. Click the “Build” button and watch the tools run in the Console window. Check for
errors in the Problems window (we have deliberately put an error in Lab1.c). When
you get an error, you will see the error message (in red) in the Problems window, and
simply double-click the error message. The editor will automatically open to the source
file containing the error, and position the mouse cursor at the correct code line.
21. Fix the error by adding a semicolon at the end of the “z = x + y” statement. For
future knowlege, realize that a single code error can sometimes generate multiple error
messages at build time. This was not the case here.
22. Build the project again. There should be no errors this time.
23. CCS can automatically save modified source files, build the program, open the debug
perspective view, connect and download it to the target, and then run the program to the
beginning of the main function.
Click on the “Debug” button (green bug) or click Target Æ Debug Active
Project.
Notice the Debug icon in the upper right-hand corner indicating that we are now in the
“Debug Perspective” view. The program ran through the C-environment initialization
routine in the rts2800_ml.lib and stopped at main() in Lab1.c.
Type &z into the address field and select “Data” memory page. Note that you must use
the ampersand (meaning “address of”) when using a symbol in a memory window
address box. Also note that Code Composer Studio is case sensitive.
Set the properties format to “Hex 16 Bit – TI Style Hex” in the window. This will give
you more viewable data in the window. You can change the contents of any address in
the memory window by double-clicking on its value. This is useful during debug.
25. Notice the watch window automatically opened and the local variables x and y are
present. (The watch window can be manually opened by clicking: View Æ Watch
Window on the menu bar). The watch window will always contain the local variables
for the code function currently being executed.
(Note that local variables actually live on the stack. You can also view local variables in
a memory window by setting the address to “SP” after the code function has been
entered).
26. We can also add global variables to the watch window if desired. Let's add the global
variable “z”.
Click the “Watch (1)” tab at the top of the watch window. In the empty box in the
“Name” column, type z and then enter. An ampersand is not used here. The watch
window knows you are specifying a symbol.
Check that the watch window and memory window both report the same value for “z”.
Trying changing the value in one window, and notice that the value also changes in the
other window.
Close the Terminate Debug Session “Cheat Sheet” by clicking on the X on the tab.
29. Next, close the project by right-clicking on Lab1 in the C/C++ Projects window
and select Close Project.
End of Exercise
Your C-source file (e.g., Adc.c) Uint16 INTPULSEPOS:1; // 2 INT pulse generation control
Uint16 ADCREFSEL:1; // 3 Internal/external reference select
#include "DSP2802x_Device.h"
Uint16 rsvd1:1; // 4 reserved
Uint16 ADCREFPWD:1; // 5 Reference buffers powerdown
Void InitAdc(void)
Uint16 ADCBGPWD:1; // 6 ADC bandgap powerdow n
{
Uint16 ADCPWDN:1; // 7 ADC powerdown
/* Reset the ADC m odule */
Uint16 ADCBSYCHN:5; // 12:8 ADC busy on a channel
AdcRegs.ADCCTL1.bit.RESET = 1;
Uint16 ADCBSY:1; // 13 ADC busy signal
Uint16 ADCENABLE:1; // 14 ADC enable
/* configure the ADC register */
Uint16 RESET:1; // 15 ADC master reset
AdcRegs.ADCCTL1.all = 0x00E4;
};
};
// Allow access to the bit fields or entire register:
union ADCCTL1_REG {
Uint16 all;
struct ADCCTL1_BITS bit;
};
// ADC External References & Function Declarations:
extern volatile struct ADC_REGS AdcRegs;
DSP2802x_Device.h
Main include file
Will include all other .h files
Include this file (directly or indirectly)
in each source file:
#include “DSP2802x_Device.h”
DSP2802x_GlobalVariableDefs.c
#include "DSP2802x_Device.h" Links each structure to
…
the address of the
peripheral using the
#pragma DATA_SECTION(AdcRegs,"AdcRegsFile");
structures named
volatile struct ADC_REGS AdcRegs; section
…
DSP2802x_Headers_nonBIOS.cmd
MEMORY Add this file to your
{ CCS project:
PAGE1:
... DSP2802x_nonBIOS.cmd
ADC: origin=0x007100, length=0x000080
...
}
SECTIONS
{
...
AdcRegsFile: > ADC PAGE = 1
...
}
Reset – Bootloader
Reset Reset vector
OBJMODE = 0 fetched from Bootloader sets
AMODE = 0 boot ROM OBJMODE = 1
ENPIE = 0 AMODE = 0
0x3F FFC0
INTM = 1
YES Emulator NO
TRST = 1 Connected ? TRST = 0
TRST = JTAG Test Reset EMU_KEY & EMU_BMODE located in PIE at 0x0D00 & 0x0D01, respectively
OTP_KEY & OTP_BMODE located in OTP at 0x3D78FE & 0x3D78FF, respectively
NO Boot Mode
EMU_KEY = 0x55AA ?
Wait
YES
NO Boot Mode
OTP_KEY = 0x55AA ?
FLASH
GPIO GPIO YES
37 34 Boot Mode OTP_BMODE = Boot Mode
0 0 Parallel I/O 0x0001 SCI
0 1 SCI 0x0004 SPI
1 0 Wait 0x0005 I2C
1 1 GetMode 0x0006 OTP
other FLASH
0x3D7800 0x3D7800
OTP (1Kw)
0x3F0000
FLASH (32Kw)
0x3F7FF6
Interrupts
Interrupt Sources
Internal Sources
TINT2
TINT1 F28x CORE
TINT0 XRS
NMI
ePWM, eCAP, PIE INT1
ADC, SCI, SPI, (Peripheral
I2C, WD Interrupt INT2
Expansion) INT3
•
•
•
External Sources
INT12
INT13
XINT1 – XINT3
INT14
TZx
XRS
INT1 1
INT2 0 C28x
Core
INT14 1
INTM
INT10.x interrupt group 28x
IFR
IER
12 Interrupts
INT11.x interrupt group Core
INT13 (TINT1)
INT14 (TINT2)
NMI
INT5
INT7
INT11
INT12 XINT3
PIE Registers
PIEIFRx register (x = 1 to 12)
15 - 8 7 6 5 4 3 2 1 0
reserved INTx.8 INTx.7 INTx.6 INTx.5 INTx.4 INTx.3 INTx.2 INTx.1
PIECTRL register 15 - 1 0
PIEVECT ENPIE
#include “DSP2802x_Device.h”
PieCtrlRegs.PIEIFR1.bit.INTx4 = 1; //manually set IFR for XINT1 in PIE group 1
PieCtrlRegs.PIEIER3.bit.INTx2 = 1; //enable EPWM2_INT in PIE group 3
PieCtrlRegs.PIEACK.all = 0x0004; //acknowledge the PIE group 3
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //enable the PIE
Internal OSC1CLK
OSC 1 0* WDCLK Watchdog
(10 MHz) 1 Module
OSCCLKSRCSEL
OSCCLKSRC2
MUX
0* CLKIN
1/n C28x
VCOCLK Core
PLL
XCLKINOFF SYSCLKOUT
XCLKIN DIV
0*
EXTCLK LOSPCP
0 1 TMR2CLKSRCSEL
X1
XTAL OSC
10 LSPCLK
11 CPUTMR2CLK
XTAL
SCI, SPI
01 All other peripherals
SYSCLKOUT 00* CPU clocked by SYSCLKOUT
X2 Timer 2
* = default
CLKIN SYSCLKOUT
1/n Core
LSPCLK
VCOCLK LOSPCP
PLL
SysCtrlRegs.LOSPCP.bit.LSPCLK
SysCtrlRegs.PLLCR.bit.DIV
LSPCLK Peripheral Clk Freq
DIV CLKIN DIVSEL n 000 SYSCLKOUT / 1
0 00 0 OSCCLK / n * (PLL bypass) 0x /4 * 001 SYSCLKOUT / 2
0 00 1 OSCCLK x 1 / n 010 SYSCLKOUT / 4 *
10 /2
011 SYSCLKOUT / 6
0 01 0 OSCCLK x 2 / n 11 /1
0 01 1 OSCCLK x 3 / n 100 SYSCLKOUT / 8
* default 101 SYSCLKOUT / 10
0 10 0 OSCCLK x 4 / n Note: /1 mode can
0 10 1 OSCCLK x 5 / n 110 SYSCLKOUT / 12
only be used when 111 SYSCLKOUT / 14
0 11 0 OSCCLK x 6 / n PLL is bypassed
0 11 1 OSCCLK x 7 / n
1 00 0 OSCCLK x 8 / n
Input Clock Fail Detect Circuitry
1 00 1 OSCCLK x 9 / n
1 01 0 OSCCLK x 10 / n PLL will issue a “limp mode” clock (1-4 MHz) if input
1 01 1 OSCCLK x 11 / n clock is removed after PLL has locked.
1 10 0 OSCCLK x 12 / n An internal device reset will also be issued (XRSn
pin not driven).
WDOVERRIDE
WDPS
WDCLK
Watchdog
/512
Prescaler WDDIS
8-bit Watchdog
Counter
CLR
WDRST
System
Reset Output
Pulse
WDCHK WDINT
55 + AA
Detector Good Key 3
/
/ Bad WDCHK Key
3
Watchdog 1 0 1
Reset Key
Register
GPIO
F2802x GPIO Grouping Overview
(lab file: Gpio.c)
GPIO Port A
Register (GPAMUX1)
[GPIO 0 to 15] GPIO Port A
Direction Register Qual
(GPADIR)
GPIO Port A Mux2 [GPIO 0 to 31]
Register (GPAMUX2)
[GPIO 16 to 31]
Input
Internal Bus
GPIO Port B
GPIO Port B
GPIO Port B Mux1 Direction Register Qual
Register (GPBMUX1) (GPBDIR)
[GPIO 32 to 38] [GPIO 32 to 38]
ANALOG Port
ANALOG I/O Mux1 ANALOG Port
Direction Register
Register (AIOMUX1) (AIODIR)
[AIO 0 to 15] [AIO 0 to 15]
SYSCLKOUT
• Setup the clock module – PLL, LOSPCP = /4, low-power modes to default values, enable
all module clocks
• Disable the watchdog – clear WD flag, disable watchdog, WD prescale = 1
• Setup watchdog system control register – DO NOT clear WD OVERRIDE bit, WD
generate a CPU reset
• Setup shared I/O pins – set all GPIO pins to GPIO function (e.g. a "00" setting for GPIO
function, and a “01”, “10”, or “11” setting for peripheral function.)
The first part of the lab exercise will setup the system initialization and test the watchdog
operation by having the watchdog cause a reset. In the second part of the lab exercise the PIE
vectors will be tested by using the watchdog to generate an interrupt. This lab will make use of
the DSP2802x C-code header files to simplify the programming of the device, as well as take care
of the register definitions and addresses. Please review these files, and make use of them in the
future, as needed.
¾ Procedure
2. In the C/C++ Projects window, click the plus sign (+) to the left of Lab2 to view
the project files. All Build Options have been configured for this lab. The files used in
this lab are:
CodeStartBranch.asm Lab_2_3.cmd
DefaultIsr_2.c Main_2.c
DelayUs.asm PieCtrl.c
DSP2802x_GlobalVariableDefs.c PieVect.c
DSP2802x_Headers_nonBIOS.cmd SysCtrl.c
Gpio.c Watchdog.c
The linker command file (Lab_2_3.cmd) has a new memory block named BEGIN_M0:
origin = 0x000000, length = 0x0002, in program memory. Additionally, the existing
memory block M0SARAM in data memory has been modified to avoid overlaps with this
new memory block.
System Initialization
4. Open and inspect SysCtrl.c. Notice that the PLL and module clocks have been
enabled.
5. Open and inspect Watchdog.c. Notice that watchdog control register (WDCR) is
configured to disable the watchdog, and the system control and status register (SCSR) is
configured to generate a reset.
6. Open and inspect Gpio.c. Notice that the shared I/O pins have been set to the GPIO
function, except for GPIO0 which will be used in the next lab exercise. Close the
inspected files.
8. Click the “Debug” button (green bug). The “Debug Perspective” view should open, the
program load automatically, and you should now be at the start of Main().
9. By default, in Emulation Boot Mode CCS is configured to automatically load values into
EMU_KEY and EMU_BMODE so that the bootloader will jump to “M0 SARAM” at
0x000000. This mode is very useful when running RAM-only based code during debug.
(Note that the default execution entry point can be changed to any of the valid boot mode
options, if desired).
11. Place the cursor on the first line of code in main() and set a breakpoint by right clicking
the mouse key and select Toggle Breakpoint. Notice that line is highlighted with a
blue dot indicating that the breakpoint has been set. Alternately, you can double-click in
the line number field to the left of the code line to set the breakpoint. The breakpoint is
set to prove that the watchdog is disabled. If the watchdog causes a reset, code execution
will stop at this breakpoint.
12. Run your code for a few seconds by using the Run button on the toolbar, or using
Target Æ Run on the menu bar. After a few seconds halt your code by using the
Halt button on the toolbar, or by using Target Æ Halt. Where did your code stop?
Are the results as expected? If things went as expected, your code should be in the
“main loop”.
13. Switch to the “C/C++ Perspective” view by clicking the C/C++ icon in the upper right-
hand corner. Modify the InitWatchdog() function to enable the watchdog (WDCR).
In Watchdog.c change the WDCR register value to 0x00A8. This will enable the
watchdog to function and cause a reset. Save the file.
14. Click the “Build” button. Select Yes to “Reload the program automatically”. Switch
back to the “Debug Perspective” view by clicking the Debug icon in the upper right-
hand corner.
15. Like before, place the cursor in the “main loop” section (on the asm(“ NOP”);
instruction line) and right click the mouse key and select Run To Line.
16. Run your code. Where did your code stop? Are the results as expected? If things went
as expected, your code should have stopped at the breakpoint. What happened is as
follows. While the code was running, the watchdog timed out and reset the processor.
The reset vector was then fetched and the ROM bootloader began execution. Since the
device is in emulation boot mode (i.e. the emulator is connected) the bootloader read the
EMU_KEY and EMU_BMODE values from the PIE RAM. These values were
previously set for boot to M0 SARAM bootmode by CCS. Since these values did not
change and are not affected by reset, the bootloader transferred execution to the
beginning of our code at address 0x000000 in the M0SARAM, and execution continued
until the breakpoint was hit in main( ).
17. Switch to the “C/C++ Perspective” view by clicking the C/C++ icon in the upper right-
hand corner. Notice that the following files are included in the project:
DefaultIsr_2.c
PieCtrl.c
PieVect.c
18. In Main_2.c, uncomment the code used to call the InitPieCtrl() function. There
are no passed parameters or return values, so the call code is simply:
InitPieCtrl();
19. Using the “PIE Interrupt Assignment Table” shown in the slides find the location for the
watchdog interrupt, “WAKEINT”. This is used in the next step.
20. In main() notice the code used to enable global interrupts (INTM bit), and in
InitWatchdog() the code used to enable the “WAKEINT” interrupt in the PIE
(using the PieCtrlRegs structure) and to enable core INT1 (IER register).
21. Modify the system control and status register (SCSR) to cause the watchdog to generate
a WAKEINT rather than a reset. In Watchdog.c change the SCSR register value to
0x0002. Save the modified files.
22. Open and inspect DefaultIsr_2.c. This file contains interrupt service routines. The
ISR for WAKEINT has been trapped by an emulation breakpoint contained in an inline
assembly statement using “ESTOP0”. This gives the same results as placing a breakpoint
in the ISR. We will run the lab exercise as before, except this time the watchdog will
generate an interrupt. If the registers have been configured properly, the code will be
trapped in the ISR.
23. Open and inspect PieCtrl.c. This file is used to initialize the PIE RAM and enable
the PIE. The interrupt vector table located in PieVect.c is copied to the PIE RAM to
setup the vectors for the interrupts. Close the modified and inspected files.
26. Run your code. Where did your code stop? Are the results as expected? If things went
as expected, your code should stop at the “ESTOP0” instruction in the WAKEINT ISR.
28. Next, close the project by right-clicking on Lab5 in the C/C++ Projects window
and select Close Project.
End of Exercise
Note: By default, the watchdog timer is enabled out of reset. Code in the file
CodeStartBranch.asm has been configured to disable the watchdog. This can be
important for large C code projects (ask your instructor if this has not already been
explained). During this lab exercise, the watchdog was actually re-enabled (or disabled
again) in the file Watchdog.c.
Control Peripherals
ADC Module
ADC Module Block Diagram
ADCINA0
ADCINA1 MUX S/H RESULT0
A A
RESULT1
ADCINA7 12-bit A/D Result
MUX
RESULT2
Converter MUX
ADCINB0
ADCINB1 MUX S/H SOC RESULT15
B B
ADCINB7
CHSEL ADC EOCx ADC ADCINT1-9
ADC full-scale Generation Interrupt
input range is Logic Logic
0 to 3.3V
SOCx Signal ADCINT1
ADCINT2
SOC0 TRIGSEL CHSEL ACQPS
SOCx Triggers
Comparator
A0
B0
A1
B1
A2
AIO2 10-bit COMP1OUT
COMP1
AIO10 DAC
B2
A3
B3
A4 ADC
AIO4 10-bit COMP2OUT
COMP2
AIO12 DAC
B4
A5
B5
A6
AIO6 10-bit COMP3OUT
COMP3
AIO14 DAC
B6
A7
B7
Comparator 3 available only on TMS320F2803x devices
t t
T
Original Signal PWM representation
DC Supply DC Supply
? PWM
Desired PWM approx.
signal to of desired
system signal
Unknown Gate Signal Gate Signal Known with PWM
ePWM
ePWM Module Signals and Connections
ePWMx -1
EPWMxSYNCI EPWMxTZINT
GPIO TZ1 – TZ3
EPWMxINT PIE
MUX
EQEP1ERR – TZ4 EPWMxA
eQEP1
GPIO
SYSCTRL
CLOCKFAIL – TZ5 ePWMx EPWMxB
MUX
EMUSTOP – TZ6
CPU
EPWMxSOCA
COMPxOUT EPWMxSOCB ADC
COMP
EPWMxSYNCO
ePWMx+1
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
TBPRD
Asymmetrical
Waveform
Count Up Mode
TBCTR
TBPRD
Asymmetrical
Waveform
TBPRD
Symmetrical
Waveform
Phase
φ=0°
En
o o .o
SyncIn
EPWM1A
CTR=zero o
CTR=CMPB o o EPWM1B
X o
SyncOut
To eCAP1
SyncIn
Phase
φ=120°
En
o o .o
SyncIn
EPWM2A φ=120°
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°
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
.. .. ..
TBPRD
CMPA Asymmetrical
CMPB Waveform
Count Up Mode
TBCTR
TBPRD
CMPA
CMPB
.. .. .. Asymmetrical
Waveform
.. .. .. ..
TBPRD
CMPA Symmetrical
CMPB Waveform
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
SW Z CA CB P Do Nothing
X X X X X
SW Z CA CB P Clear Low
↓ ↓ ↓ ↓ ↓
SW Z CA CB P Set High
↑ ↑ ↑ ↑ ↑
SW Z CA CB P Toggle
T T T T T
TBCTR
TBPRD
. .
. .
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
. .
. .
CA CB CA CB
↑ ↓ ↑ ↓
EPWMA
Z Z Z
T T T
EPWMB
. . . . . . . .
TBPRD
CA CA CA CA
↑ ↓ ↑ ↓
EPWMA
CB CB CB CB
↑ ↓ ↑ ↓
EPWMB
TBPRD
. . . .
CA CB CA CB
↑ ↓ ↑ ↓
EPWMA
Z P Z P
↓ ↑ ↓ ↑
EPWMB
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
supply rail
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
EPWMxA
EPWMxB
CHPFREQ
EPWMxA
EPWMxB
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
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
Sensors EPWM1A
CPU
P
core EPWM1B W
COMPxOUT Digital
Compare M
EPWMxTZINT •
O
TZ1 Cycle-by-Cycle • U
TZ2
Mode • T
TZ3 P
eQEP1
TZ4 EQEP1ERR EPWMxA U
TZ5 CLOCKFAIL
One-Shot T
SYSCTRL EPWMxB S
TZ6 EMUSTOP Mode
CPU
Shadowed Shadowed
Clock Compare Compare
Prescaler Register Register
16-Bit
Compare Action Dead
Time-Base
TBCLK Logic Qualifier Band
Counter
EPWMxSYNCI EPWMxSYNCO
Period
Register EPWMxA
PWM Trip
Shadowed
Chopper Zone
SYSCLKOUT EPWMxB
TZy
Digital TZ1-TZ3
Compare COMPxOUT
. . . . . . . .
TBPRD
CMPB
CMPA
EPWMA
EPWMB
CTR = 0
CTR = PRD
CTR = 0 or PRD
CTRU = CMPA
CTRD = CMPA
CTRU = CMPB
CTRD = CMPB
Regular
Device Clock PWM Step
(i.e. 60 MHz) (i.e. 16.67 ns)
HRPWM
Micro Step (~150 ps)
eCAP
Capture Module (eCAP)
Timer
Trigger
pin
Timestamp
Values
CAP2POL
Capture 2 Polarity
Event Logic
CAP4POL
Capture 4 Polarity
Register Select 4
Shadowed
Period
Period shadow
Register mode
immediate Register (CAP3)
mode
(CAP1)
32-Bit PWM
Time-Stamp Compare
Counter Logic ECAP
pin
SYSCLKOUT
Compare
immediate Register
mode Compare
shadow
(CAP2) Register mode
Shadowed (CAP4)
eQEP
Ch. A
Ch. B
shaft rotation
(00) (11)
increment decrement
(A,B) = counter 10 counter
(10) (01)
Illegal
Ch. A 00 Transitions;
generate 11
phase error
interrupt
Ch. B
01
Quadrature Decoder
State Machine
Ch. A
Quadrature Ch. B
Capture
EQEPxA/XCLK
32-Bit Unit EQEPxB/XDIR
Time-Base Quadrature
QEP Decoder EQEPxI Index
Watchdog
EQEPxS Strobe
from homing sensor
SYSCL KOUT
Position/Counter
Compare
The objective of this lab is to demonstrate and become familiar with the operation of the on-chip
analog-to-digital converter and ePWM. ePWM1A will be setup to generate a 2 kHz, 25% duty
cycle symmetric PWM waveform. The waveform will then be sampled with the on-chip analog-
to-digital converter and displayed using the graphing feature of Code Composer Studio. The
ADC has been setup to sample a single input channel at a 50 kHz sampling rate and store the
conversion result in a buffer in the MCU memory. This buffer operates in a circular fashion, such
that new conversion data continuously overwrites older results in the buffer.
Two ePWM modules have been configured for this lab exercise:
• Used as a timebase for triggering ADC samples (period match trigger SOCA)
ePWM1
TB Counter CPU copies
data
Compare ADC result to
memory
connector
wire buffer during
Action Qualifier RESULT0
pointer rewind
ADC ISR
ADC-
INA0
...
View ADC
buffer PWM
ePWM2 triggering Samples
ADC on period match
using SOCA trigger every
20 µs (50 kHz) ePWM2 Code Composer
Studio
The software in this exercise configures the ePWM modules and the ADC. It is entirely interrupt
driven. The ADC end-of-conversion interrupt will be used to prompt the CPU to copy the results
of the ADC conversion into a results buffer in memory. This buffer pointer will be managed in a
circular fashion, such that new conversion results will continuously overwrite older conversion
results in the buffer. The ADC interrupt service routine (ISR) will also toggle LED LD2 on the
Piccolo™ ControlSTICK as a visual indication that the ISR is running.
Notes
• ePWM1A is used to generate a 2 kHz PWM waveform
• Program performs conversion on ADC channel A0 (ADCINA0 pin)
• ADC conversion is set at a 50 kHz sampling rate
• ePWM2 is triggering the ADC on period match using SOCA trigger
• Data is continuously stored in a circular buffer
• Data is displayed using the graphing feature of Code Composer Studio
• ADC ISR will also toggle the LED LD2 as a visual indication that it is running
¾ Procedure
2. In the C/C++ Projects window, click the plus sign (+) to the left of Lab3 to view
the project files. All Build Options have been configured for this lab. The files used in
this lab are:
Adc.c Gpio.c
CodeStartBranch.asm Lab_2_3.cmd
DefaultIsr_3_4.c Main_3.c
DelayUs.asm PieCtrl.c
DSP2802x_GlobalVariableDefs.c PieVect.c
DSP2802x_Headers_nonBIOS.cmd SysCtrl.c
EPwm.c Watchdog.c
Note: DO NOT make any changes to Gpio.c and EPwm.c – ONLY INSPECT
3. Open and inspect Gpio.c by double clicking on the filename in the project window.
Notice that the shared I/O pin in GPIO0 has been set for the ePWM1A function. Next,
open and inspect EPwm.c and see that the ePWM1 has been setup to implement the
PWM waveform as described in the objective for this lab. Notice the values used in the
following registers: TBCTL (set clock prescales to divide-by-1, no software force, sync
and phase disabled), TBPRD, CMPA, CMPCTL (load on 0 or PRD), and AQCTLA (set
on up count and clear on down count for output A). Software force, deadband, PWM
chopper and trip action has been disabled. (Note that the last steps enable the timer count
mode and enable the clock to the ePWM module). See the global variable names and
values that have been set using #define in the beginning of the Lab.h file. Notice that
ePWM2 has been initialized earlier in the code for the ADC. Close the inspected files.
5. Click the “Debug” button (green bug). The “Debug Perspective” view should open, the
program load automatically, and you should now be at the start of Main().
Note: Exercise care when connecting any wires, as the power to the ControlSTICK is on,
and we do not want to damage the ControlSTICK! Details of pin assignments can be
found on the last page of this lab exercise.
7. Using a connector wire provided, connect the PWM1A (pin # 17) to ADCINA0 (pin # 3)
on the ControlSTICK.
8. Run your code for a few seconds by using the Run button on the toolbar, or using
Target Æ Run on the menu bar. After a few seconds halt your code by using the
Halt button on the toolbar, or by using Target Æ Halt. Verify that the ADC result
buffer contains the updated values.
9. Open and setup a graph to plot a 50-point window of the ADC results buffer.
Click: Tools Æ Graph Æ Single Time and set the following values:
10. The graphical display should show the generated 2 kHz, 25% duty cycle symmetric
PWM waveform. The period of a 2 kHz signal is 500 μs. You can confirm this by
measuring the period of the waveform using the “measurement marker mode” graph
feature. Right-click on the graph and select Measurement Marker Mode. Move
the mouse to the first measurement position and left-click. Again, right-click on the
graph and select Measurement Marker Mode. Move the mouse to the second
measurement position and left-click. The graph will automatically calculate the
difference between the two values taken over a complete waveform period. When done,
clear the measurement points by right-clicking on the graph and select Remove All
Measurement Marks.
Click: Tools Æ Graph Æ FFT Magnitude and set the following values:
FFT Order 10
12. On the plot window, hold the mouse left-click key and move the marker line to observe
the frequencies of the different magnitude peaks. Do the peaks occur at the expected
frequencies?
13. The memory and single time graph windows displaying AdcBuf should still be open. The
connector wire between PWM1A (pin # 17) and ADCINA0 (pin # 3) should still be
connected. In real-time mode, we would like to have our window continuously refresh
faster than the default rate. Click:
Window Æ Preferences…
and in the section on the left select the “CCS” category. Click the plus sign (+) to the left
of “CCS” and select “Debug”. In the section on the right change the following:
Click OK.
Note: This change to the “Continuous refresh interval” causes all enabled continuous
refresh windows to refresh at a faster rate. This can be problematic when a large number
of windows are enabled, as bandwidth over the emulation link is limited. Updating too
many windows can cause the refresh frequency to bog down. In this case you can just
selectively enable continuous refresh for the individual windows of interest.
14. Next we need to enable the graph window for continuous refresh. In the upper right-hand
corner of the graph window, left-click on the yellow icon with the arrows rotating in a
circle over a pause sign. Note when you hover your mouse over the icon, it will show
“Enable Continuous Refresh”. This will allow the graph to continuously
refresh in real-time while the program is running.
15. Enable the memory window for continuous refresh using the same procedure as the
previous step.
16. Run the code and watch the windows update in real-time mode. Click:
17. Carefully remove and replace the connector wire from ADCINA0 (pin # 3). Are the
values updating as expected?
20. Next, close the project by right-clicking on Lab2 in the C/C++ Projects window
and select Close Project.
Optional Exercise
You might want to experiment with this code by changing some of the values or just modify the
code. Try generating another waveform of a different frequency and duty cycle. Also, try to
generate complementary pair PWM outputs. Next, try to generate additional simultaneous
waveforms by using other ePWM modules. Hint: don’t forget to setup the proper shared I/O pins,
etc. (This optional exercise requires some further working knowledge of the ePWM.
Additionally, it may require more time than is allocated for this lab. Therefore, you may want to
try this after the class).
End of Exercise
1 2 3 4
ADC-A7 ADC-A2 ADC-A0 3V3
COMP1 (+VE) Vref-HI
5 6 7 8
ADC-A4 ADC-B1 EPWM-4B TZ1
COMP2 (+VE) GPIO-07 GPIO-12
9 10 11 12
SCL ADC-B6 EPWM-4A ADC-A1
GPIO-33 GPIO-06
13 14 15 16
SDA ADC-B7 EPWM-3B 5V0
GPIO-32 GPIO-05
17 18 19 20
EPWM-1A ADC-B4 EPWM-3A SPISOMI
GPIO-00 COMP2 (-VE) GPIO-04 GPIO-17
21 22 23 24
EPWM-1B ADC-B3 EPWM-2B SPISIMO
GPIO-01 GPIO-03 GPIO-16
25 26 27 28
SPISTE ADC-B2 EPWM-2A GND
GPIO-19 COMP1 (-VE) GPIO-02
29 30 31 32
SPICLK GPIO-34 PWM1A-DAC GND
GPIO-18 (LED) (Filtered)
Flash Programming
Flash Programming Basics
Flash Programming Basics
The DSP CPU itself performs the flash programming
The CPU executes Flash utility code from RAM that reads the
Flash data and writes it into the Flash
We need to get the Flash utility code and the Flash data into RAM
FLASH CPU
RS232 SCI
Bootloader
SPI
ROM
Flash
Data I2C
GPIO
TMS320F2802x
Algorithm Function
1. Erase - Set all bits to zero, then to one
2. Program - Program selected bits with zero
3. Verify - Verify flash contents
0x000A80
Flash Registers
0x008000
L0 SARAM (4Kw)
0x009000
reserved
0x3D7800 Dual
User OTP (1Kw)
0x3D7C00 reserved
0x3D7C80 Mapped
ADC / OSC cal. data
0x3D8000 reserved
0x3F0000
FLASH (32Kw)
0x3F7FF8 PASSWORDS (8w )
0x3F8000
L0 SARAM (4Kw)
0x3F9000
CSM Password
0x3F0000
Device unlocked
Correct Yes
password? User can access on-
chip secure memory
No
The objective of this lab is to program and execute code from the on-chip flash memory. The
TMS320F28027 device has been designed for standalone operation in an embedded system.
Using the on-chip flash eliminates the need for external non-volatile memory or a host processor
from which to bootload. In this lab, the steps required to properly configure the software for
execution from internal flash memory will be covered.
pointer rewind
Compare
Action Qualifier CPU copies
connector result to
wire buffer during
ADC ISR
...
ePWM2 triggering
ADC on period match
using SOCA trigger every
20 µs (50 kHz) ePWM2 View ADC
buffer PWM
Samples
¾ Procedure
2. In the C/C++ Projects window, click the plus sign (+) to the left of Lab4 to view
the project files. All Build Options have been configured for this lab. The files used in
this lab are:
Adc.c Gpio.c
CodeStartBranch.asm Lab_4.cmd
DefaultIsr_3_4.c Main_4.c
DelayUs.asm Passwords.asm
DSP2802x_GlobalVariableDefs.c PieCtrl.c
DSP2802x_Headers_nonBIOS.cmd PieVect.c
EPwm.c SysCtrl.c
Flash.c Watchdog.c
Each initialized section actually has two addresses associated with it. First, it has a LOAD
address which is the address to which it gets loaded at load time (or at flash programming time).
Second, it has a RUN address which is the address from which the section is accessed at runtime.
The linker assigns both addresses to the section. Most initialized sections can have the same
LOAD and RUN address in the flash. However, some initialized sections need to be loaded to
flash, but then run from RAM. This is required, for example, if the contents of the section needs
to be modified at runtime by the code.
3. Open and inspect the linker command file Lab_4.cmd. Notice that a memory block
named FLASH_ABCD has been been created at origin = 0x3F0000, length = 0x007F80
on Page 0. This flash memory block length has been selected to avoid conflicts with
other required flash memory spaces. See the reference slide at the end of this lab exercise
for further details showing the address origins and lengths of the various memory blocks
used.
4. In Lab_4.cmd the following compiler sections have been linked to on-chip flash
memory block FLASH_ABCD:
Compiler Sections:
5. Open and inspect InitPieCtrl() in PieCtrl.c. Notice the memcpy() function used to
initialize (copy) the PIE vectors. At the end of the file a structure is used to enable the
PIE.
6. Open and inspect Flash.c. The C compiler CODE_SECTION pragma is used to place
the InitFlash() function into a linkable section named “secureRamFuncs”.
7. The “secureRamFuncs” section will be linked using the user linker command file
Lab_4.cmd. Open and inspect Lab_4.cmd. The “secureRamFuncs” will load to
flash (load address) but will run from L0SARAM (run address). Also notice that the
linker has been asked to generate symbols for the load start, load end, and run start
addresses.
While not a requirement from a MCU hardware or development tools perspective (since
the C28x MCU has a unified memory architecture), historical convention is to link code
to program memory space and data to data memory space. Therefore, notice that for the
L0SARAM memory we are linking “secureRamFuncs” to, we are specifiying “PAGE
= 0” (which is program memory).
8. Open and inspect Main_4.c. Notice that the memory copy function memcpy() is being
used to copy the section “secureRamFuncs”, which contains the initialization
function for the flash control registers.
9. The following line of code in main() is used call the InitFlash() function. Since
there are no passed parameters or return values the code is just:
InitFlash();
The CSM module also requires programming values of 0x0000 into flash addresses 0x3F7F80
through 0x3F7FF5 in order to properly secure the CSM. Both tasks will be accomplished using a
simple assembly language file Passwords.asm.
10. Open and inspect Passwords.asm. This file specifies the desired password values
(DO NOT CHANGE THE VALUES FROM 0xFFFF) and places them in an initialized
section named “passwords”. It also creates an initialized section named “csm_rsvd”
which contains all 0x0000 values for locations 0x3F7F80 to 0x3F7FF5 (length of 0x76).
11. Open Lab_4.cmd and notice that the initialized sections for “passwords” and
“csm_rsvd” are linked to memories named PASSWORDS and CSM_RSVD,
respectively.
12. Open and inspect CodeStartBranch.asm. This file creates an initialized section
named “codestart” that contains a long branch to the C-environment setup routine.
This section has been linked to a block of memory named BEGIN_FLASH.
13. In the earlier lab exercises, the section “codestart” was directed to the memory
named BEGIN_M0. Open and inspect Lab_4.cmd and notice that the section
“codestart” will now be directed to BEGIN_FLASH. Close the inspected files.
On power up the reset vector will be fetched and the ROM bootloader will begin execution. If
the emulator is connected, the device will be in emulator boot mode and will use the EMU_KEY
and EMU_BMODE values in the PIE RAM to determine the bootmode. This mode was utilized
in an earlier lab. In this lab, we will be disconnecting the emulator and running in stand-alone
boot mode (but do not disconnect the emulator yet!). The bootloader will read the OTP_KEY
and OTP_BMODE values from their locations in the OTP. The behavior when these values have
not been programmed (i.e., both 0xFFFF) or have been set to invalid values is boot to flash
bootmode.
Build – Lab.out
14. Click the “Build” button to generate the Lab.out file to be used with the CCS Flash
Programmer. Check for errors in the Problems window.
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.
Clicking the “Debug” button in the C/C++ Perspective will automatically launch the
debugger, connect to the target, and program the flash memory in a single step.
15. Program the flash memory by clicking the “Debug” button (green bug). As soon as the
“Progress Information” box opens, if needed select “Details” in order to watch the
programming operation and status. After successfully programming the flash memory
the “Progress Information” box will close.
16. Flash programming options are configured with the “On-Chip Flash” control panel.
Open the control panel by clicking:
Scroll the control panel and notice the various options that can be selected. You will see
that specific actions such as “Erase Flash” can be performed.
The CCS on-chip flash programmer was automatically configured to use the Piccolo™
10 MHz internal oscillator as the device clock during programming. Notice the “Clock
Configuration” settings has the OSCCLK set to 10 MHz, the DIVSEL set to /2, and the
PLLCR value set to 12. Recall that the PLL is divided by two, which gives a
SYSCLKOUT of 60 MHz.
The flash programmer should be set for “Erase, Program, Verify” and all boxes in the
“Erase Sector Selection” should be checked. We want to erase all the flash sectors.
We will not be using the on-chip flash programmer to program the “Code Security
Password”. Do not modify the Code Security Password fields. They should remain as
all 0xFFFF.
17. Close the “On-Chip Flash” control panel by clicking the X on the tab.
20. Single-Step by using the <F5> key (or you can use the Step Into button on the
horizontal toolbar) through the bootloader code until you arrive at the beginning of the
codestart section in the CodeStartBranch.asm file. (Be patient, it will take about
21. Step a few more times until you reach the start of the C-compiler initialization routine at
the symbol _c_int00.
22. Now do Target Æ Go Main. The code should stop at the beginning of your
main()routine. If you got to that point succesfully, it confirms that the flash has been
programmed properly, that the bootloader is properly configured for jump to flash mode,
and that the codestart section has been linked to the proper address.
23. You can now RUN the CPU, and you should observe the LED on the ControlCARD
blinking. Try resetting the CPU, select the EMU_BOOT_FLASH boot mode, and then
hitting RUN (without doing all the stepping and the Go Main procedure). The LED
should be blinking again.
26. Next, close the project by right-clicking on Lab4 in the C/C++ Projects window
and select Close Project.
30. The LED should be blinking, showing that the code is now running from flash memory.
End of Exercise
origin =
0x3F 0000
FLASH
length = 0x7F80
page = 0 Lab_4.cmd
SECTIONS
{
0x3F 7F80 CSM_RSVD codestart :> BEGIN_FLASH, PAGE = 0
length = 0x76 passwords :> PASSWORDS, PAGE = 0
page = 0 csm_rsvd :> CSM_RSVD, PAGE = 0
0x3F 7FF6 BEGIN_FLASH }
length = 0x2
page = 0
0x3F 7FF8 PASSWORDS
length = 0x8
page = 0
4
0x3F 7FF6 LB
_c_int00 5
“user” code sections
Passwords (8w) main ( )
{
……
3 ……
……
0x3F E000 Boot ROM (8Kw) }
Boot Code
0x3F F7BB
{SCAN GPIO}
2
BROM vector (32w)
0x3F FFC0 0x3F F7BB
1
RESET
Development Tools
C2000 Experimenter’s Kits
F28027, F28035, F2808, F28335
Development Support
C2000 Signal Processing Libraries
Signal Processing Libraries & Applications Software Literature #
ACI3-1: Control with Constant V/Hz SPRC194
ACI3-3: Sensored Indirect Flux Vector Control SPRC207
ACI3-3: Sensored Indirect Flux Vector Control (simulation) SPRC208
ACI3-4: Sensorless Direct Flux Vector Control SPRC195
ACI3-4: Sensorless Direct Flux Vector Control (simulation) SPRC209
PMSM3-1: Sensored Field Oriented Control using QEP SPRC210
PMSM3-2: Sensorless Field Oriented Control SPRC197
PMSM3-3: Sensored Field Oriented Control using Resolver SPRC211
PMSM3-4: Sensored Position Control using QEP SPRC212
BLDC3-1: Sensored Trapezoidal Control using Hall Sensors SPRC213
BLDC3-2: Sensorless Trapezoidal Drive SPRC196
DCMOTOR: Speed & Position Control using QEP without Index SPRC214
Digital Motor Control Library (F/C280x) SPRC215
Communications Driver Library SPRC183
DSP Fast Fourier Transform (FFT) Library SPRC081
DSP Filter Library SPRC082
DSP Fixed-Point Math Library SPRC085
DSP IQ Math Library SPRC087
DSP Signal Generator Library SPRC083
DSP Software Test Bench (STB) Library SPRC084
C28x FPU Fast RTS Library SPRC664
DSP2802x C/C++ Header Files and Peripheral Examples SPRC832
http://processors.wiki.ti.com/index.php/Hands-On_Training_for_TI_Embedded_Processors
FAQ: http://www-k.ext.ti.com/sc/technical_support/knowledgebase.htm
Device information my.ti.com
Application notes News and events
Technical documentation Training
Enroll in Technical Training: http://www.ti.com/sc/training
Email: epic@ti.com
NOTES: