Tutorial-Using SCI For Real-Time Monitoring in TI F28335 Target
Tutorial-Using SCI For Real-Time Monitoring in TI F28335 Target
-1-
Powersim Inc.
www.powersimtech.com
With the SimCoder Module and the TI F28335 Target, PSIM can generate ready-to-run codes for
DSP boards that use TI floating-point DSP F28335. By using the Serial Communication Interface
(SCI) blocks in the TI F28335 Target library, PSIM offers the capability to display waveforms and
change parameters inside the DSP in real time. This makes it extremely easy to test, debug, and
adjust DSP control code in a non-disruptive and non-intrusive way.
This tutorial describes the SCI blocks, SCI cable, and the setup procedure in the PSIM schematic
and in hardware to achieve the real-time monitoring.
To illustrate the process, we will use the circuit 3-ph sine wave with SCI monitoring.psimsch as
an example. This example is located in the sub-folder examples\SimCoder\TI F28335 Target\3-ph
sine wave with SCI in the PSIM directory. We will generate the code from this circuit and run it on
the TI TMS320F28335 Experimenter Kit (TI Part Number TMDSDOCK28335).
To keep the original example unchanged, we will copy the whole folder to c:\TI SCI, and use this
folder as the working folder in this tutorial.
1. SCI in TI F28335
The TI F28335 DSP has 3 SCI ports: SCIA, SCIB, and SCIC. Each SCI port can use different
GPIO ports for communication, as listed below :
For SCIA:
-
GPIO28 as the SCI receiving (Rx, or input) pin, and GPIO29 as the SCI transmitting
(Tx, or output) pin.
GPIO35 as the receiving pin, and GPIO36 as the transmitting pin.
For SCIB:
-
For SCIC:
-
PSIM will support only one of the above SCI port combinations at any time as RS-232.
2. RS-232 Cable
To communicate with the computer, a RS-232 cable is needed to connect the DSP board to the
computer. This cable needs 3 wires: One for receiving (Rx), one for transmitting (Tx), and
another for ground (Gnd). The connections on each end of the cable are shown below:
On DSP board side
Cable
Tx
Rx
Gnd
On computer side
Rx
Tx
Gnd
-2-
Powersim Inc.
www.powersimtech.com
A 9-pin DB-9 connector (female) is used on the cable so that it can be connected to the
computer serial port. If a computer does not have the serial port, an USB/RS-232 serial adapter
with the DB-9 connector (male) needs to be used.
The figure below shows the connection diagram of the cable made for the TI evaluation kits.
The DSP end consists of a 4-pin header connector, and the computer end uses a 9-pin DB-9
connector (female) to connect to the computer serial port. If a computer does not have a serial
port, an USB/RS-232 serial adapter with the DB-9 connector (male) can be used.
Tx
V33
Gnd
Rx
To DSP
board
Tx
To computer or
USB/RS-232
adaptor
Gnd
Rx
TI kit board
A picture of the TI Experimenter kit, the cable, and the USB/RS-232 serial adaptor is shown
below. On the Experimenter kit, the 4-pin connector is labelled as "Tx V33 Gnd Rx".
Cable
TI kit
4-pin connector
for the cable
Note that if the USB/RS-232 adaptor is used, one needs to first install the driver that comes with
the adaptor before using it.
After the USB/RS-232 adaptor driver is installed, plug in the adaptor to the computer and open
computer Device Manager from the Control Panel to find the RS-232 port number, as shown
below. The figure shows that the RS-232 serial port is COM3.
-3-
Powersim Inc.
www.powersimtech.com
If there are multiple serial devices connected to the computer, try to unplug the USB/RS-232
adaptor and plug it back in to find out the port number. Remember this port number as it is
needed in PSIM when defining the communication with DSP.
3. Testing the Communication between DSP and Computer
To test if the communication between DSP and the computer works, or to isolate and debug the
problem if the communication does not work, perform the three tests below.
Test 1: DSP Only
In this test, a DSP program will send out the data through the SCI port. The RS-232 cable will
be shorted so that the data will be looped back and the DSP will receive the same data that it
sends out. If the test is successful, it means that the serial communication on the DSP side is
working.
Follow the steps below to perform the test:
-
Connect the TI Experimenter kit to the computer through the USB cable. Turn on the
power on the Experimenter kit. Launch the CodeComposerStudio (CCS) setup, and
make sure that "F28335 XDS100 USB Emulator" is selected. Exit the setup and launch
CCS. Connect to the DSP board by selecting Debug -> Connect.
Connect the 4-pin connector end of the RS-232 cable to the 4-pin connector (labelled as
"Tx V33 Gnd Rx") on the Experimenter kit board.
Use a wire to short the Rx pin (pin 2) and Tx pin (pin 3) of the DB-9 connector, as
shown here:
-4-
Powersim Inc.
www.powersimtech.com
In CCS, select File -> Load Program, and go to the PSIM folder under "SimCoder\DSP
RxTx Test", and select the file DSP_RxTx_Test.out,out to load the code to the DSP
RAM memory. For the dialog message "Code Composer could not locate
DSP2833x_CodeStartBranch.asm. Would you like to browse for it?", choose No.
In CCS, select Debug -> Reset CPU to reset the DSP. Then select Debug -> Restart to
restart the DSP, and select Debug -> Go Main to go to the entry point of the main
function. On the dialog message "Code Composer could not locate: DoutSci.c. Would
you like to browse for it?", choose No. Then select Debug -> Run to run the code.
If the communication works, the two red LED lights LD2 and LD3 on the F28335
controlCard should be on. The location of these two LED's are shown below (circled in
red):
Connect the USB adapter to the computer, and the DB-9 end of the RS-232 cable to the
USP adapter.
Use a wire to short the Rx pin and Tx pin of the 4-pin connector of the RS-232 cable.
In CCS, select File -> Load Program, and go to the PSIM folder under "SimCoder\DSP
RxTx Test", and select the file DSP_RxTx_Test.out,out to load the code to the DSP
RAM memory.
Launch PSIM. Select Utilities -> DSP Oscilloscope. Set the correct serial port number.
Set the baud rate as 115200, and parity as None.
Click on the Test button. If the communication works, the dialog will show "The test is
successful".
-5-
Powersim Inc.
www.powersimtech.com
Set up in the same way as in Test 1. But instead of shorting the Rx and Tx pins of the
DB-9 connector, connect the DB-9 connector to the USB adapter, and connect the USB
adapter to the computer.
On the DSP Oscilloscope, click on the Test button. If the communication works, the two
red LED lights on the DSP controlCard will blink for around 3 sec. before they are off,
and the computer program will report "The test is successful".
4. Setting up in PSIM
In PSIM, load the schematic file 3-ph sine wave with SCI monitoring.psimsch in the folder
"examples\TI F28335 Target\3-ph since wave with SCI", as shown on the left below. The TI
F28335 Target library menu is shown on the right.
In this circuit, there are 3 types of SCI library elements: SCI Configuration (highlighted in
green), SCI Input (highlighted in grey), and SCI Output (highlighted in yellow), as explained in
the sections below. These elements can be accessed by going to Elements -> SimCoder -> TI
F28335 Target.
4.1 SCI Configuration
The SCI Configuration element has four parameters:
-
SCI Port:
-6-
Powersim Inc.
www.powersimtech.com
Speed (bps):
Parity Check:
-7-
Powersim Inc.
www.powersimtech.com
-8-
Powersim Inc.
www.powersimtech.com
Also, set the baud rate and the parity check to be the same as defined in the SCI
Configuration element in PSIM. In this example, the baud rate is set to 115200bps, and
the parity check is set to None.
Under Operation mode, choose Continuous. In the Continuous operation mode, data are
sent from DSP to the computer continuously. In the case where the communication
speed is not fast enough to send out all the data, some data will be lost and the Data
Integrity (shown at the lower left corner) will be less than 100%.
On the other hand, in the Snap-shot operation mode, every data point in the DSP buffer
will be sent out, and the complete data set will be displayed on the DSP Oscilloscope.
After all the data in the buffer are sent out, the buffer will be refilled. In this mode, the
data is not continuous, but a snap-shot is captured every time.
Click on the Connect button in the lower left corner to connect the computer to the DSP.
If connection is successful, all output and input variables will be displayed in the left
side of the window, as shown in the figure below.
-9-
Powersim Inc.
www.powersimtech.com
Make sure that the communication speed and parity check settings in the DSP
Oscilloscope are the same as in the SCI Configuration element in PSIM.
Make sure that the RS-232 cable is connected properly on both ends.
Make sure that the DSP external clock on the DSP hardware is same as the
setting in the DSP Clock element in PSIM.
- If the problem still persists, please run the tests as described in Section 3.
To display waveforms of output variables defined by the SCI Output elements, select
the variables from the All Variables column, and click on the >> button to move them
to the Selected variables column. The waveforms of the selected variables will be
displayed in the scope, as shown below.
To remove a variable from display, highlight it in the Selected variables column, and
click on the << button.
Input variables are the parameters that can be changed in the DSP code. Input variables
are defined either by the SCI Input elements (such as the SCI Input element AngleStep in
this example), or if a parameter is defined as a global variable (such as the variable Amp
in this example).
- 10 -
Powersim Inc.
www.powersimtech.com
To change an input variable, enter the new value in the edit box, and click on Update.
The new value will be sent to DSP. For example, when the input variable AngleStep is
changed from 1 to 0.5, the frequency of the waveforms will be reduced by half.
The lower left corner of the oscilloscope also shows the Data Integrity. If the data
integrity is 100%, it means that all the data collected have been successfully transmitted
and displayed.
If the data integrity is less than 100%, it means that some data points are lost due to the
fact that the requested data amount is too large and the DSP does not have enough
resource to send it. If this occurs, show a fewer number of waveforms, or increase the
Data Point Step value in the SCI Output elements, so that fewer number of data points
need to be transmitted and displayed. Alternatively, one can change the Operation Mode
from Continuous to Snap-shot.
Click on the Pause button to halt the data acquisition, or the Disconnect button to
disconnect the computer from the DSP.
- 11 -
Powersim Inc.
www.powersimtech.com
If the size of the buffer is too big to locate in the RAM memory, CCS will report a link error as
below:
"C:\TI SCI\3-ph sine wave with SCI monitoring (C code)\F28335_RAM_Lnk.cmd", line 47:
error: run placement fails for object ".ebss"
When CCS reports a link error like this, try to reduce the buffer size, or compile and run the
generated code in the "Flash Release" mode.
- 12 -
Powersim Inc.
www.powersimtech.com