Professional Documents
Culture Documents
References: TBD
The modern computer hovers between the obsolescent and the nonexistent.
— Sydney Brenner, attributed in Science, 5 January 1990.
CampCAEN Wireless – Summer 2010 Page 1/71 Tuesday – June 29, 2010
TMS320F28335 Experimenter Kit
CampCAEN Wireless – Summer 2010 Page 2/71 Tuesday – June 29, 2010
Two components
Docking board.
◮ Supports various processor control cards.
◮ Connects to PC via USB cable.
◮ Powered via the USB cable.
◮ Hole pattern to be used for user circuits.
◮ We’ve added wire wrap pins and sockets to allow access to signals
and to support future additions.
CampCAEN Wireless – Summer 2010 Page 4/71 Tuesday – June 29, 2010
Documentation on USB drives
CampCAEN Wireless – Summer 2010 Page 5/71 Tuesday – June 29, 2010
The index list
CampCAEN Wireless – Summer 2010 Page 6/71 Tuesday – June 29, 2010
Poking around
CampCAEN Wireless – Summer 2010 Page 7/71 Tuesday – June 29, 2010
F28335 Peripherals
CampCAEN Wireless – Summer 2010 Page 8/71 Tuesday – June 29, 2010
F28335 block diagram
M0 SARAM 1Kx16 L0 SARAM 4K x 16 OTP 1K x 16
(0-Wait) (0-Wait, Dual Map)
M1 SARAM 1Kx16 L1 SARAM 4K x 16
(0-Wait) (0-Wait, Dual Map)
Flash
L2 SARAM 4K x 16 256K x 16
(0-Wait, Dual Map) Code 8 Sectors
Security
Memory Bus
L3 SARAM 4K x 16 Module
(0-Wait, Dual Map)
L4 SARAM 4K x 16 TEST2
(0-W Data, 1-W Prog) Pump
TEST1
L5 SARAM 4K x 16 PSWD
Boot ROM (0-W Data, 1-W Prog) Flash
8K x 16 Wrapper
L6 SARAM 4K x 16
(0-W Data, 1-W Prog)
L7 SARAM 4K x 16
(0-W Data, 1-W Prog)
Memory Bus
XD31:0
FPU
TCK
XHOLDA
TDI
XHOLD
TMS
XREADY
32-bit CPU
TDO
88 GPIOs GPIO XR/W (150 MHZ @ 1.9 V)
XINTF
MUX (100 MHz @ 1.8 V) TRST
XZCS0
EMU0
XZCS7
EMU1
XZCS6
Memory Bus
XWE0
DMA Bus
XCLKIN
XA0/XWE1 CPU Timer 0
OSC, X1
DMA PLL,
XA19:1 CPU Timer 1
6 Ch LPM, X2
WD
CPU Timer 2 XRS
XCLKOUT
XRD PIE
(Interrupts)
EPWMxA
EPWMxB
SCIRXDx
SCITXDx
SPICLKx
ESYNCO
MCLKRx
SPISTEx
MCLKXx
CANRXx
EQEPxA
EQEPxB
EQEPxS
CANTXx
ESYNCI
EQEPxI
MFSRx
MFSXx
ECAPx
MDXx
MRXx
SDAx
SCLx
TZx
GPIO MUX
88 GPIOs
Secure zone
CampCAEN Wireless – Summer 2010 Page 9/71 Tuesday – June 29, 2010
Processor and devices
Memory Bus
XD31:0
FPU
TCK
XHOLDA
TDI
XHOLD
TMS
XREADY
32-bit CPU
TDO
88 GPIOs GPIO XR/W (150 MHZ @ 1.9 V)
XINTF
MUX (100 MHz @ 1.8 V) TRST
XZCS0
EMU0
XZCS7
EMU1
XZCS6
Memory Bus
XWE0
DMA Bus
XCLKIN
XA0/XWE1 CPU Timer 0
OSC, X1
DMA PLL,
XA19:1 CPU Timer 1
6 Ch LPM, X2
WD
CPU Timer 2 XRS
XCLKOUT
XRD PIE
(Interrupts)
EPWMxA
EPWMxB
SCIRXDx
SCITXDx
SPICLKx
ESYNCO
MCLKRx
SPISTEx
MCLKXx
CANRXx
EQEPxA
EQEPxB
EQEPxS
CANTXx
ESYNCI
EQEPxI
MFSRx
MFSXx
ECAPx
MDXx
MRXx
SDAx
SCLx
TZx
GPIO MUX
88 GPIOs
Secure zone
CampCAEN Wireless – Summer 2010 Page 10/71 Tuesday – June 29, 2010
Comments
◮ Obligatory slide.
◮ Gives an, albeit complex, overview of the device.
◮ Illustrates the structure of the device. How the processor, memory
and peripherals are interconnected.
CampCAEN Wireless – Summer 2010 Page 11/71 Tuesday – June 29, 2010
Memory overview
Memory Bus
CampCAEN Wireless – Summer 2010 Page 12/71 Tuesday – June 29, 2010
F28335 memory layout
Block
On-Chip Memory External Memory XINTF
Start Address
0x00 0000
M0 Vector - RAM (32 x 32)
(Enabled if VMAP = 0)
Low 64K
Peripheral Frame 3
(Protected) DMA-Accessible
0x00 6000
Peripheral Frame 1
(Protected) Reserved
0x00 7000
Peripheral Frame 2
(Protected)
0x00 8000
L0 SARAM (4K x 16, Secure Zone, Dual-Mapped)
0x00 9000 L1 SARAM (4K x 16, Secure Zone, Dual-Mapped)
Reserved
0x00 A000
L2 SARAM (4K x 16, Secure Zone, Dual-Mapped)
0x00 B000
L3 SARAM (4K x 16, Secure Zone, Dual-Mapped)
0x00 C000
L4 SARAM (4K x 16, DMA-Accessible)
0x00 D000
L5 SARAM (4K x 16, DMA-Accessible)
0x00 E000
L6 SARAM (4K x 16, DMA-Accessible)
0x00 F000
L7 SARAM (4K x 16, DMA-Accessible)
0x01 0000
0x10 0000
Reserved XINTF Zone 6 (1M x 16, XZCS6) (DMA-Accessible)
0x20 0000
XINTF Zone 7 (1M x 16, XZCS7) (DMA-Accessible)
0x30 0000
0x30 0000 FLASH (256K x 16, Secure Zone)
0x33 FFF8
128-bit Password
0x34 0000 Reserved
0x38 0080
ADC Calibration Data
0x38 0090
Reserved
0x38 0400
User OTP (1K x 16, Secure Zone)
0x38 0800
Reserved
0x3F 8000
L0 SARAM (4K x 16, Secure Zone, Dual-Mapped)
(24x/240x Equivalent
0x3F 9000
L1 SARAM (4K x 16, Secure Zone, Dual-Mapped)
Program Space)
Reserved
0x3F A000
High 64K
0x3F FFC0
BROM Vector - ROM (32 x 32)
(Enabled if VMAP = 1, ENPIE = 0)
LEGEND:
Only one of these vector maps-M0 vector, PIE vector, BROM vector- should be enabled at a time.
CampCAEN Wireless – Summer 2010 Page 14/71 Tuesday – June 29, 2010
How does it do that?
The F28335 can (in effect) accomplish this every clock cycle. How?
CampCAEN Wireless – Summer 2010 Page 15/71 Tuesday – June 29, 2010
Executes in separate phases
CampCAEN Wireless – Summer 2010 Page 16/71 Tuesday – June 29, 2010
Simplified pipeline activity
Example 4−3. Simplified Diagram of Pipeline Activity
F1 F2 D1 D2 R1 R2 E W Cycle
I1 1
I2 I1 2
I3 I2 I1 3
I4 I3 I2 I1 4
I5 I4 I3 I2 I1 5
I6 I5 I4 I3 I2 I1 6
I7 I6 I5 I4 I3 I2 I1 7
I8 I7 I6 I5 I4 I3 I2 I1 8
I8 I7 I6 I5 I4 I3 I2 9
I8 I7 I6 I5 I4 I3 10
I8 I7 I6 I5 I4 11
I8 I7 I6 I5 12
I8 I7 I6 13
I8 I7 14
I8 15
CampCAEN Wireless – Summer 2010 Page 17/71 Tuesday – June 29, 2010
Do I need to get involved?
CampCAEN Wireless – Summer 2010 Page 18/71 Tuesday – June 29, 2010
Composer Studio v4
CampCAEN Wireless – Summer 2010 Page 19/71 Tuesday – June 29, 2010
C/C++ screen
CampCAEN Wireless – Summer 2010 Page 20/71 Tuesday – June 29, 2010
Comments
CampCAEN Wireless – Summer 2010 Page 21/71 Tuesday – June 29, 2010
Debug screen
CampCAEN Wireless – Summer 2010 Page 22/71 Tuesday – June 29, 2010
Comments
CampCAEN Wireless – Summer 2010 Page 23/71 Tuesday – June 29, 2010
After clicking the bug icon
CampCAEN Wireless – Summer 2010 Page 24/71 Tuesday – June 29, 2010
Comments
◮ Clicking the bug button in the C/C++ mode might not switch to the
debug mode. You can do so manually.
◮ Program execution will actually start at c_int00 and proceed to
main where it will wait.
◮ To start execution click on the green triangle at the top of the debug
panel.
CampCAEN Wireless – Summer 2010 Page 25/71 Tuesday – June 29, 2010
Key concepts
CampCAEN Wireless – Summer 2010 Page 26/71 Tuesday – June 29, 2010
Creating a C project
◮ C/C++ mode.
◮ File.
◮ New, CCS Project
◮ Enter the name of the project.
◮ Next. Take the default for the type of project.
◮ Next. No additional project settings are needed.
◮ Next. Make sure the Device Variant is TMS320F28335. Otherwise
don’t make any other changes.
◮ Finish.
CampCAEN Wireless – Summer 2010 Page 27/71 Tuesday – June 29, 2010
Choosing a target configuration
◮ C/C++ mode.
◮ File.
◮ New, Target Configuration File.
◮ I typically specify the name to be the same as the project name.
◮ Finish.
◮ Connection. Texas Instruments XDS100v 1 USB Emulator.
◮ Device. Check the Experimenter’s Kit – Delfino F28335 box.
◮ Save.
◮ Can now clear the configuration window. Click the trailing × in the
tab.
CampCAEN Wireless – Summer 2010 Page 28/71 Tuesday – June 29, 2010
Configuration selection screen
CampCAEN Wireless – Summer 2010 Page 29/71 Tuesday – June 29, 2010
Hello World Exercise
CampCAEN Wireless – Summer 2010 Page 30/71 Tuesday – June 29, 2010
Create your own Hello World
CampCAEN Wireless – Summer 2010 Page 31/71 Tuesday – June 29, 2010
Some times things get out of sync
CampCAEN Wireless – Summer 2010 Page 32/71 Tuesday – June 29, 2010
Basic Hello World code
#include <stdio.h>
void main(void)
{
printf("Hello World!\n");
}
CampCAEN Wireless – Summer 2010 Page 33/71 Tuesday – June 29, 2010
Looping Hello World
Modify your hello world code to be as shown below, compile and run.
#include <stdio.h>
#define N 5
void main(void)
{
int counter;
CampCAEN Wireless – Summer 2010 Page 34/71 Tuesday – June 29, 2010
Comments
CampCAEN Wireless – Summer 2010 Page 35/71 Tuesday – June 29, 2010
Increasing the loop size
Why?
CampCAEN Wireless – Summer 2010 Page 36/71 Tuesday – June 29, 2010
The watchdog timer
CampCAEN Wireless – Summer 2010 Page 37/71 Tuesday – June 29, 2010
Leashing the watchdog
Add the three lines of code below the declaration of counter,
rebuild and run. All should be well.
#include <stdio.h>
#define N 20
void main(void)
{
int counter;
asm(" eallow");
*(volatile int *)0x007029 = 0x0068;
asm(" edis");
CampCAEN Wireless – Summer 2010 Page 38/71 Tuesday – June 29, 2010
What have we done?
CampCAEN Wireless – Summer 2010 Page 39/71 Tuesday – June 29, 2010
Doing more
#include <stdio.h>
#define N 20
#define EALLOW asm(" eallow")
#define EDIS asm(" edis")
#define WDCR *(volatile int *)0x007029
void main(void)
{
int counter;
EALLOW;
WDCR = 0x0068;
EDIS;
CampCAEN Wireless – Summer 2010 Page 40/71 Tuesday – June 29, 2010
Comments
CampCAEN Wireless – Summer 2010 Page 41/71 Tuesday – June 29, 2010
End of the Hello World exercise
CampCAEN Wireless – Summer 2010 Page 42/71 Tuesday – June 29, 2010
Conventions
CampCAEN Wireless – Summer 2010 Page 43/71 Tuesday – June 29, 2010
Blinking an LED Exercise
CampCAEN Wireless – Summer 2010 Page 44/71 Tuesday – June 29, 2010
Thinking things through
◮ We need to know how the LEDs connect to the F28335. A good place
to determine this is by checking the board documentation provided
by TI. TI provides excellent documentation with all of their
products.
◮ We next need to learn how to control the signals used to turn the
LEDs on and/or off.
◮ Finally we should write a small program to verify that we correctly
understand what we are doing.
CampCAEN Wireless – Summer 2010 Page 45/71 Tuesday – June 29, 2010
F28335 control card schematic
CampCAEN Wireless – Summer 2010 Page 46/71 Tuesday – June 29, 2010
Zooming to the LEDs
CampCAEN Wireless – Summer 2010 Page 47/71 Tuesday – June 29, 2010
Investigating the GPIO lines
CampCAEN Wireless – Summer 2010 Page 48/71 Tuesday – June 29, 2010
Relevant GPIO control/configuration registers
From sprufb0d.pdf.
CampCAEN Wireless – Summer 2010 Page 49/71 Tuesday – June 29, 2010
What do we see?
CampCAEN Wireless – Summer 2010 Page 50/71 Tuesday – June 29, 2010
Controlling a Group A or B GPIO setting
From sprufb0d.pdf.
CampCAEN Wireless – Summer 2010 Page 51/71 Tuesday – June 29, 2010
Defines that we might want create
CampCAEN Wireless – Summer 2010 Page 52/71 Tuesday – June 29, 2010
Next, what bits to set/clear?
CampCAEN Wireless – Summer 2010 Page 53/71 Tuesday – June 29, 2010
There are two mux registers.
bits: . . . 7 6 5 4 3 2 1 0
GPIO: . . . 03/35 02/34 01/33 00/32
Setting these bits to zero (actually the default setting) results in direct
digital I/O.
CampCAEN Wireless – Summer 2010 Page 54/71 Tuesday – June 29, 2010
Getting down to code
To initialize:
To toggle:
GPATOGGLE = 0x80000000;
CampCAEN Wireless – Summer 2010 Page 55/71 Tuesday – June 29, 2010
Final product
/* File name: BlinkLED.c
*
* 24Jun2010 .. initial version .. km
*
*/
void main()
{
unsigned long counter=0L;
while(FOREVER) {
while (counter++ <200000); //200 thousand
counter = 0L;
EALLOW;
GPATOGGLE = 0x80000000;
EDIS;
}
}
CampCAEN Wireless – Summer 2010 Page 56/71 Tuesday – June 29, 2010
Frosting on the cake
◮ Can we extrapolate the above code to also blink the second LED?
◮ The second LED is driven GPIO line 34 which is in group B.
◮ Using the toggle get the second LED to blink.
◮ Once blinking can we arrange our code so that B is on when is off
and vice versa? Perhaps by directly setting and clearing rather than
toggling.
◮ Give it a go.
Hints:
◮ Use GPBMUX1 (0x6F96), GPBDIR (0x6F9A), GPBPUD (0x6F9C),
◮ Group B least significant bit(s) correspond to GPIO pin 32.
CampCAEN Wireless – Summer 2010 Page 57/71 Tuesday – June 29, 2010
End of the Blinking LED exercise
CampCAEN Wireless – Summer 2010 Page 58/71 Tuesday – June 29, 2010
A useful function
void DisableDog(void)
{
asm(" EALLOW");
*(unsigned int *)0x007029 = 0x0068; // WDCR
asm(" EDIS");
}
CampCAEN Wireless – Summer 2010 Page 59/71 Tuesday – June 29, 2010
The basic processor
CampCAEN Wireless – Summer 2010 Page 60/71 Tuesday – June 29, 2010
Memory basics
CampCAEN Wireless – Summer 2010 Page 61/71 Tuesday – June 29, 2010
Execute from RAM or Flash Memory?
CampCAEN Wireless – Summer 2010 Page 62/71 Tuesday – June 29, 2010
C memory organization
CampCAEN Wireless – Summer 2010 Page 63/71 Tuesday – June 29, 2010
Initialized sections
From spru514c.pdf.
CampCAEN Wireless – Summer 2010 Page 64/71 Tuesday – June 29, 2010
Uninitialized sections
◮ .bss reserves space for global and static variables. At startup the
boot routine copies data from the .cinit section to initialize
values. Warning, non-initialized variables are not necessarily set to
0!
◮ .ebss as above using far memory.
◮ .stack allocates space for the execution stack. This is used to pass
arguments to functions and to allocate space for local variables.
◮ .sysmem provides space for dynamic memory allocation. (malloc
and calloc manage this).
◮ .esystem as above in far memory.
From spru514c.pdf.
CampCAEN Wireless – Summer 2010 Page 65/71 Tuesday – June 29, 2010
Comment
From spru514c.pdf.
CampCAEN Wireless – Summer 2010 Page 66/71 Tuesday – June 29, 2010
The F28335 limits.h
/*****************************************************************************/
/* limits.h v5.2.3 */
/* Copyright (c) 1996-2009 Texas Instruments Incorporated */
/*****************************************************************************/
#ifndef _LIMITS
#define _LIMITS
#if defined(__TMS320C28X__)
#else
#endif
#endif /* _LIMITS */
CampCAEN Wireless – Summer 2010 Page 67/71 Tuesday – June 29, 2010
Hmmm
How do these sizes compare with those found using Visual Studio?
CampCAEN Wireless – Summer 2010 Page 68/71 Tuesday – June 29, 2010
Exercise
Run the visual studio sizeof check on the Code Composer Studio C
compiler.
CampCAEN Wireless – Summer 2010 Page 69/71 Tuesday – June 29, 2010
A TI solution
//---------------------------------------------------------------------------
// For Portability, User Is Recommended To Use Following Data Type Size
// Definitions For 16-bit and 32-Bit Signed/Unsigned Integers:
//
#ifndef DSP28_DATA_TYPES
#define DSP28_DATA_TYPES
typedef int int16;
typedef long int32;
typedef long long int64;
typedef unsigned int Uint16;
typedef unsigned long Uint32;
typedef unsigned long long Uint64;
typedef float float32;
typedef long double float64;
#endif
These can be found in various TI supplied header files. I’ve also placed a
copy in the workspace (our creation) include directory in the file
DSP28_DATA_TYPES.h.
CampCAEN Wireless – Summer 2010 Page 70/71 Tuesday – June 29, 2010
Use of sizeof
To compute the size of a given array. For example: given Array, use
ArraySize = sizeof(Array)/sizeof(Array[0]);
This allows writing code that is essentially able to work with any specific
array size.
For example, to send out an array of sequence bits to the D/A converter,
independent of the size of the array, one might write
N = sizeof(sequence_array)/sizeof(char);
for (i = 0; i < N; i++) {
DacOut0(sequence_array[i]);
}
Changing the size of the sequence array leaves the code unchanged.
CampCAEN Wireless – Summer 2010 Page 71/71 Tuesday – June 29, 2010