I'm trying to do a custom profiler for which i just need the PC(program Counter) value periodically.
I looked into the AN0043 but it just says DWT could be used for PC sampling but doesn't deal with the details.
1.How do i setup my (EFM32WG)MCU to output PC data continuously.
2.If I do the PC sampling, will i be able to switch the MCU to lower energy modes till M4;-) ?
3.Once my MCU starts sending the PC data on the SWO , is it possible to access the info into some kind external script like C/Python?
Lastly , I'm not finding the register details of the ITM in the Reference manual , it would be great if somebody could point to it.
1. See the function BSP_TraceSwoSetup() in bsp_trace.c which is included in all examples for the WG STK in Simplicity Studio. This is the setup we use for our profiler.
2. Basically, yes. But there will not be any PC samples in EM1-4, since the core isn't running. Also, if a debugger has connected to the chip, it will stay in EM1 instead of going to EM2/3 to keep the debug connection working. This is resolved by a pin reset (i.e. pushing the reset button). See: http://community.silabs.com/t5/Simplicity-Studio-and-Software/Advanced-Energy-Monitor-AEM-current-measurements-don-t-match-the/ta-p/137997
3. I would look into what you can do with Segger's software tools (segger.com). For example, I think you can use the command line interface of J-Link Commander to dump samples, but I haven't really done this. You can also use the J-Link Dll directly (that's what we do), but this requires an SDK license from Segger.
Lastly, I think you will find what you need in the ARM Cortex M4 Technical Reference Manual: http://infocenter.arm.com/help/topic/com.arm.doc.100166_0001_00_en/arm_cortexm4_processor_trm_100166_0001_00_en.pdf
Thanks for the reply,
I was wondering if SWO messages(PC inf) sent by 'BSP_TraceSwoSetup()' could be decoded/visible in Jlink SWO viewer ?
It doesn't seem like that works, since I can't seem to be able to control the clock frequency used by the SWO viewer, and the automatic configuration doesn't seem to work.
What I did manage to do, though, is to do this using the J-Link Commander using the following commands:
sworead <number of bytes>
swoflush <number of bytes>
You can also use swoshow to get parsed samples out instead of raw data.
Note that the number of bytes is interpreted as hex, i.e. sworead 100 == sworead 0x100 and returns 256 bytes.
I'm not clear how the PC samples are encoded are they into ascii or encapsulated in some message.
Could you please explain in detail how to get the PC.
I would have to look that up in the documentation just like you. I guess you can find everything you need at http://infocenter.arm.com/help/index.jsp
If you don't want to dig into that, perhaps you could just use J-Link Commander's "swoshow"? It gives you the PC in ASCII:
68 bytes read (68 bytes in host buffer)
Offset Data Meaning
0000-0002 0E 21 10 Exception 33 (Entry)
0003-0005 0E 21 20 Exception 33 (Exit)
0006-0008 0E 00 30 Exception 0 (Return)
0009-000B 0E 16 10 Exception 22 (Entry)
000C-000E 0E 16 20 Exception 22 (Exit)
000F-0011 0E 00 30 Exception 0 (Return)
0012-0016 17 02 2F 00 00 PC = 0x00002F02
0017-001B 17 02 2F 00 00 PC = 0x00002F02
001C-0020 17 06 2F 00 00 PC = 0x00002F06
0021-0025 17 02 2F 00 00 PC = 0x00002F02
0026-002A 17 02 2F 00 00 PC = 0x00002F02
002B-002F 17 06 2F 00 00 PC = 0x00002F06
0030-0034 17 FE 2E 00 00 PC = 0x00002EFE
0035-0039 17 02 2F 00 00 PC = 0x00002F02
003A-003E 17 02 2F 00 00 PC = 0x00002F02
003F-0043 17 0C 33 00 00 PC = 0x0000330C