AN204432 FM3 FM4 Trace with μVision and ULINK Pro.pdf

AN204432
FM3, FM4 Trace with µVision and ULINK Pro
Target Product: All FM3, FM4 series with trace ports
This application notes describes how setup the trace functionality with KEIL’s µVision tool chain using the ULINK Pro
JTAG/TRACE adapter.
Contents
1
Introduction ...............................................................1
1.1
About Document ..............................................1
2
µVision Configuration ...............................................1
2.1
Configure Flash Tools… ..................................1
2.2
Debugger Configuration ...................................3
2.3
Trace Port Enable ............................................3
1
Introduction
1.1
About Document
3
Debug Session with µVision ..................................... 5
3.1
Trace Window .................................................. 5
3.2
Saving Trace Data ........................................... 6
4
Document History ..................................................... 7
This application notes describes how setup the trace functionality with KEIL’s µVision tool chain using the ULINK Pro
JTAG/TRACE adapter.
2
µVision Configuration
2.1
Configure Flash Tools…
Via the menu Flash→Configure Flash Tools… the Options for Target ‘Name’ window will open.
Within this dialog window choose the tab Debug. Then select ULINK Pro Cortex Debugger and then Settings.
www.cypress.com
Document No. 002-04432 Rev. *A
1
FM3, FM4 Trace with µVision and ULINK Pro
The Cortex-M Target Driver Setup window will open. Choose the Trace tab.
In this configuration window the following settings have to be adjusted mandatory:




Core Clock (FM3: e.g. 80 MHz, FM4: e.g. 160 MHz)
Trace Port: Sync Trace Port with 4-bit Data
Trace Enable
ETM Trace Enable
The remaining settings depend on the needs of the user.
www.cypress.com
Document No. 002-04432 Rev.*A
2
FM3, FM4 Trace with µVision and ULINK Pro
2.2
Debugger Configuration
On the tab Debug check the SWJ box and choose SW for the Port drop down box to adjust the ULINK Pro to serial
wire debug.
2.3
Trace Port Enable
The debug ini script should be adjusted for trace usage.
A typical debug initialization script may look like the following code. The necessary trace ports and pins enable is
highlighted in dark red bold characters. These lines enable the port pins for trace. Note that at Port 0 also the JTAG
pins have to be kept (write 0x000003FF).
www.cypress.com
Document No. 002-04432 Rev.*A
3
FM3, FM4 Trace with µVision and ULINK Pro
Example for FM4 (MBF568R):
/* Initialization Script for Debug RAM */
FUNC void Setup (void) {
SP = _RDWORD(0x1FFF8000);
PC = _RDWORD(0x1FFF8004);
_WDWORD(0xE000ED08, 0x1FFF8000);
Register
_WDWORD(0x4006F500, 0xF07FFFFF);
_WDWORD(0x40063000, 0x000003FF);
_WBYTE(0x40063603, 0x03);
// Setup Stack Pointer
// Setup Program Counter
// Setup Vector Table Offset
// ADE.AN19...23 = 0
// PFRs for Port P00 to P09
// TRC0E, TRC1E of EPFR00
}
load %L incremental
Setup();
// Setup for Running
g, main
Example for FM3 (MBF506N):
/* Initialization Script for Debug RAM */
FUNC void Setup (void) {
SP = _RDWORD(0x1FFF8000);
PC = _RDWORD(0x1FFF8004);
_WDWORD(0xE000ED08, 0x1FFF8000);
Register
_WDWORD(0x40033000, 0x000003FF);
_WBYTE(0x40033603, 0x03);
// Setup Stack Pointer
// Setup Program Counter
// Setup Vector Table Offset
// PFRs for Port P00 to P09
// TRC0E, TRC1E of EPFR00
}
load %L incremental
Setup();
// Setup for Running
g, main
Note: FM3 and FM4 have different GPIO base addresses. The differences are shown in the table below.
Register
FM3 address
FM4 address
EPFR0
0x40033600
0x40063600
PFR0
0x40033000
0x40063000
ADE
0x4003F000
0x4006F000
Note, that the JTAG port pins must be preserved, so that the access to EPFR00 should be done for the upper byte
where the trace enable bits are located. Thus the offset for the EPFR00 base address is 3.
www.cypress.com
Document No. 002-04432 Rev.*A
4
FM3, FM4 Trace with µVision and ULINK Pro
Attention:
If the trace pins share analog inputs, these analog inputs
must be switched off by using the GPIO’s ADE register.
Check the pin layout, which analog inputs your device
share with these trace pins.
2.3.1
Trace Port with 2-Bit Data
If only TRACECLK, TRACED0, TRACED1 should be used by writing 0x01 to 0x40033603, Sync Trace Port with 2bit Data has to be selected in the Cortex-M Target Driver Setup dialog:
3
Debug Session with µVision
3.1
Trace Window
Now the IDE and the MCU are prepared for trace usage.
Start the debug session with the µVision IDE. In the View menu choose Trace→Trace Data.
The Trace Data window will open.
In the Display combo box with the top down list choose ETM – Code Exec HLL. The ITM items use a reduced trace
functionality via the JTAG port.
www.cypress.com
Document No. 002-04432 Rev.*A
5
FM3, FM4 Trace with µVision and ULINK Pro
A pop up window will occur after stopping the application.
After code execution and following stop the trace window will look like the following example.
3.2
Saving Trace Data
With the disk symbol
the trace data can be exported to a CSV file.
The options are to save the full buffer a time interval or a selection of the trace window. Note, that the save process
may take some longer time, depending of the size of the trace data.
The CSV file looks like the following excerpt.
# C:/work/Trace.csv : uVision Trace Data Export - CSV
#
#
Index,Time (in s),Address / Port,Instruction / Data,Src Code / Trigger Addr,Function
"0","0.736783500",X : 0x1FFF058A," B
0x1FFF0578","
while(1)","main"
"1","0.736783500",X : 0x1FFF0578," BL.W
GetCharMfs0 (0x1FFF052E)","
u8Char = GetCharMfs0();","main"
"2","0.736783500",X : 0x1FFF052E," LDR
r0,[pc,#104] ; @0x1FFF0598","
if ((FM4_MFS0->SSR & 0xE0u) != 0u) // Check for errors PE, ORE,
FRE","GetCharMfs0"
"3","0.736783500",X : 0x1FFF054E," LDR
r0,[pc,#72] ; @0x1FFF0598","
else if (FM4_MFS0->SSR & 0x04u)
// RDRF?","GetCharMfs0"
"4","0.736783500",X : 0x1FFF0568," MOVS
r0,#0x00","
return 0u;
// Nothing received","GetCharMfs0"
"5","0.736783500",X : 0x1FFF054C," BX
lr"," }","GetCharMfs0"
"6","0.736783625",X : 0x1FFF057E," CBZ
r4,0x1FFF058A","
if ((0u != u8Char) && (0xFFu != u8Char))","main"
www.cypress.com
Document No. 002-04432 Rev.*A
6
FM3, FM4 Trace with µVision and ULINK Pro
4
Document History
Document Title: AN204432 - FM3, FM4 Trace with µVision and ULINK Pro
Document Number: 002-04432
ECN
Orig. of
Change
**

MAWI
03/06/2014
Initial Release
*A
5034126
MAWI
12/02/2015
Converted Spansion Application Note “FM3_FM4_AN706-00082-1v0-E” to Cypress
format
Revision
www.cypress.com
Submission
Date
Description of Change
Document No. 002-04432 Rev.*A
7
FM3, FM4 Trace with µVision and ULINK Pro
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
Automotive
cypress.com/go/automotive
psoc.cypress.com/solutions
Clocks & Buffers
cypress.com/go/clocks
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Interface
cypress.com/go/interface
Cypress Developer Community
Lighting & Power Control
cypress.com/go/powerpsoc
Memory
cypress.com/go/memory
PSoC
cypress.com/go/psoc
Touch Sensing
cypress.com/go/touch
USB Controllers
cypress.com/go/usb
Wireless/RF
cypress.com/go/wireless
Spansion Products
spansion.com/products
Community | Forums | Blogs | Video | Training
Technical Support
cypress.com/go/support
All other trademarks or registered trademarks referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2014-2015. The information contained herein is subject to change without notice. Cypress Semiconductor
Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any
license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or
safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as
critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies
Cypress against all charges.
This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide
patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a
personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative
works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress
integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the
right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or
use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a
malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems
application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
www.cypress.com
Document No. 002-04432 Rev.*A
8