Você está na página 1de 13

PSIM

P M Tuttoria
al
Auto Code
C Gener
G ration ffor F28
833x T
Targett

Jaanuary 20155

-1- Pow
wersim Inc.
www.powersimtech.com
Auto
A Code Gen
neration for F
F2833x Targett

PSIM’s SimCoder
S Module,
M combbined with F2833x
F Harddware Targett, can generaate ready-to--run
code for hardware baased on TI F2833x seriess floating-pooint DSP.
This tuto
orial describees, in step by
y step, how to
t generate ccode in PSIM
M, compile aand upload thhe code
in Code Composer
C Studio (CCS)), and run it ono the DSP.
To illustrrate the proccess, we use the circuit “T
TI 1-ch DC//DC buck.pssimsch’ as ann example. T
This
example is located in n the sub-fold
der “examplles\SimCodeer\F2833x Taarget\TI 1-CCh DC-DC” in the
PSIM dirrectory.
To keep the
t original example uncchanged, wee will copy thhe whole follder to “c:\ T
TI 1-Ch DC--DC”,
and use this
t folder ass the working
g folder in th
his tutorial.

1. PSIM
M Setup for
fo Code Generation
G n
In PSIM,, load the sch
hematic file “TI_DC_DC
C_Buck_1_cch.psimsch”” as shown below.

As comppared to other PSIM circu uits not for code


c generattion, this circcuit containss elements frrom the
F2833x Hardware
H Taarget library. In this circu
uit, there aree two F2833x Hardware Target libraary
elements: a 16-chann
nel A/D conv verter and a 1-phase PW WM Generatoor, as shown below on thhe left.
33x Hardwarre Target lib
The F283 brary can be accessed byy going to Ellements >> SimCoder >
>>
F2833x Target.
T A list of the librrary is shown
n below on tthe right.

-6- Poweersim Inc.


www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

F2833x Tarrget library lisst:

F283
335 Hardwaree elements
used in the circuit

Like any other circuiits, this circu


uit can be sim
mulated by sselecting Sim
mulate >> R
Run Simulattion.

1.1 Simulation Control


C Parameters
Before peerforming th he code geneeration, first define the pproject configguration for Code Compposer
Studio. Double
D click on the Simuulation Contrrol block (thhe clock imaage). The Haardware Tarrget
should bee set to F28333x. Click on
o the drop-d down menu tto choose onne of the fouur project setttings. In
this case,, we will cho
oose RAM Debug,
D as sho own below.

With the RAM Debu ug setting, it is easy to deebug the pro gram and thhere is no neeed to write thhe
program to the flash memory.

-7- Poweersim Inc.


www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

1.2 Generating
G Code
C
To generrate code, sellect Simulatte >> Generrate Code. T
The generateed code will be displayedd in a
separate window, as shown below w.

PSIM no ot only generrates the codde, but also generates


g all the necessarry project filles for four
configuraations: RAM
M Debug, RA AM Release, Flash Releaase, and Flassh RAM Rellease. The prroject
file and all
a dependen nt files are sto
ored in a sub
b-folder calleed “c:\TI 1-C
Ch DC-DC\
TI_DC_D DC_Buck_1_ch (C codee)”.

2. CCS
S Setup
The PSIM M generated project is fo
or CCS v3.3,, the Code C
Composer Stuudio from T TI should be vversion
3.3 or hig
gher. If you are using CC
CS v3.3, the project can be opened ddirectly; If using CCS 4 or
higher, you
y need to useu CCS’s Im mport Legacyy v3.3 Projeect function. We use CC CS v5.5 to shhow the
way to lo
oad and debu ocument for the examplee.
ug the prograam in this do

2.1 Im
mport Projeect into CCS
Launch CCS
C v5.5, iff this is the fiirst time you
u load the prooject, you neeed to transffer CCS v3.33 project
to CCS v5.5
v project by b go to Pro oject >> Imp port Legacyy CCSv3.3 P Project. Thee following ddialog
pops up. click on "Brrowse..." buttton to choosse " C:\TI 1--Ch DC-DC\\TI_DC_DC C_Buck_1_chh (C
code)\TI_
_DC_DC_B Buck_1_ch.pjjt" then click k "Next" buttton.

-8- Poweersim Inc.


www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

When thee following dialog


d displaayed, click "Finish"
" buttton to start pproject transffer.

he transformed project w
If there iss no transferr problem, th will be autom
matically loadded. The CC
CS will
appear ass follows:

-9- Poweersim Inc.


www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

Note thatt the project configuratio


on is set to RAM
R Debug . With this ssetting, all prrogram and ddata
will be lo
oaded to the RAM memo ory.

2.2 Compiling
C Code
C
To comp pile the projeect, right mou use click on the project nname ("TI_D DC_DC_Buck_1_ch") inn the
pane of Project
P Explo orer, then cliick on "Build Project" inn the poppedd up menu. O Or click on thhe
project name in the pane
p of Projeect Explorer to select it aas the currennt project (thhe project namme
changes to
t bold) then n select Projject >> Builld to build thhe project orr Project >> Rebuild Alll to
rebuild th
he whole pro oject). After the compilin ng is compleete, CCS willl display thee following:

- 10 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

The warnning message can be ignored. This warning


w messsage is displlayed when pprogram is nnot
saved in the flash meemory.

2.3 Set Target Configuratio


C on
oading a prog
Before lo gram to the target,
t we neeed to createe a target connfiguration ffor the targett board
(Assume that a TI’s TMS320F28
T 8335 controlCARD is ussed). Select V View -> Tarrget
Configurrations, a paane of Targeet Configurattions displayys as followss in CCS.

Right mo
ouse click on n "User Defiined" in the Target
T Confi
figuration paane then select "New Tarrtget
Configurration" in thee popped up menu. A diaalog displayss as below.

- 11 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

Change the
t file namee as you wannt (here is "F
F2833x", thee file extensioon will be "cccxml"), then click
"Finish" button. A neew pane nam
med "F2833x x.ccxml" dispplays in CCS S as below.

In "Connnection" com
mbo box, cho oose the emuulator you wiill use (for eexample, "Sppectrum Digiital
C2000 XDS510LC
X Emulator"),
E then
t check "TMS320F288335" in thee list box of ""Board of Device".
Click "Saave" button to
t save the configuration
c n.
Back to the
t "Target Configuratio
C ons" pane, rigght mouse cllick on "F28833x.ccxml" configuratioon,
move mo ouse to "Linkk File to Proj
oject" in the popped
p up m
menu, all proojects will bee displayed iin the
sub-menu u. Select "TII_DC_DC_B Buck_1_ch" project, thenn check if "F F2833x.ccxm ml" is added to the
project in
n the "Projecct Explorer" pane. See beelow.

3. Targ
get Hardw
ware Setup
p
Insert TI’s TMS320F
F28335 contrrolCARD in
nto TI’s 2-Chhannel DC/D
DC Buck Coonverter Kit
(TMDSD DCDC2KIT)), as shown below.
b

- 12 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

Connect the J1 conneector of the board


b to the JTAG emullator, and theen connect thhe JTAG em
mulator
to the com
mputer’s US
SB port. Afteer connectingg the power to the boardd, turn on Sw
witches SW11 and
SW2 on thet board. Switch SW3 is i for display
ying either C
Ch1 or Ch2 ooutput. Set S
SW3 to the C
Ch2
position.

4. Run
nning Codee in DSP Target
T
4.1 Load
L Code to DSP Targ
get
In CCS, click
c on "TI__DC_DC_B Buck_1_ch" project
p to seet it as the cuurrent projecct (the currennt
project name displayys bold), then n select Runn >> Debug tto connect thhe computerr to the DSP. If the
connectioon is successsful, the prog
gram will bee upload to thhe target, thee F28335 DS SP will
automatically reset annd run to thee start place of main funnction as show wn below.

- 13 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

4.2 Uploading
U Code
C to DSP (Flash Releease Version
n)
There aree 4 configuraation optionss in the geneerated projecct: RamReleaase, RamDebbug, FlashR Release
and FlashhRamReleasse. RamReleease and Ram mDebug uplooad program m to DSP RA AM area; Insttead,
FlashRellease and FlaashRamRelease upload program
p to D
DSP flash memory but F FlashRamRellease
will automatically co opy the progrram to RAM M and all codde will be runn in RAM. T To use a diffferent
configuraation, right mouse
m click on the project name in thhe Project E
Explorer panee, move mouuse to
"Build Configuration ns" in the poppped up men nu and selecct a configuraation you waant as below
w.

After chaanging configuration, thee project neeed to be com


mpiled again,, then the codde can be upploaded
to the DS
SP with the same
s method d described ata 5. Uploadding Code too DSP (RAM M Debug Veersion).

4.3 Run
R Code in
n DSP Targeet
To run thhe code in thhe DSP, we can
c use the to oolbar in "D
Debug" pane as shown rigght to resum
me, stop,
step into,, step over an
nd step returrn to run the program.

5. Monitoring Waveform
W s with PSIIM’s DSP Oscilloscope
At the en
nd of Section
ns Error! Reeference souurce not fouund., the codde is runningg in the targeeted
DSP to generate
g a co
onverter outp
put of 3.3V (+/-0.05V).
( N
Now, one maay use PSIM M’s DSP

- 14 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

Oscillosccope feature to monitor the


t variabless inside the D
DSP and to ccontrol the cconverter outtput
voltage.
Connect the SCI portt of the hardw
ware target to
t the compuuter.
Launch PSIM.
P Selectt Utilities >>
> DSP Oscillloscope. Thhis will launcch the DSP O
Oscilloscopee as
shown beelow.

Set the co
orrect serial port numberr, baud rate, and parity ccheck. They must be idenntical to thesse in the
SCI Conffiguration bllock in the PSIM
P circuit.
Click thee Connect bu utton at the leeft bottom of the scope ppanel. All naames of SCI output and input
variabless will be listeed on the left
ft side of the panel, as shhown below.

- 15 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

The two variables av


vailable for monitoring
m arre Vfdbk annd Ref_out. S
Select the vaariables to diisplay
on the scope screen.
To changge the DC-D
DC converter output voltaage, modify the value Vrref to 2 and click the Up pdate
button. The
T LED disp play of the converter
c boaard will channge to the neew value. Thhe figure bellow
shows the waveforms with the neew value of Vref.
V

6. Cod
de Composer Studio
o Referencces
For furth
her informatiion about thee Texas Instrrument’s Coode Composeer Studio, please refer too the
documen nts in the link
ks below.

- 16 - Poweersim Inc.
www.powersim
mtech.com
Auto
A Code Gen
neration for F
F2833x Targett

 CCSv5
C Getting
g Started GuideCCSv5 Getting Started Guide
htttp://processsors.wiki.ti.com/index..php/CCSv55_Getting_S
Started_Guide

- 17 - Poweersim Inc.
www.powersim
mtech.com

Você também pode gostar