Hi,
My setup involves Kinetis KV3x family micro and GCC compiler. What is the best mechanism to access the value of PC during runtime for logging purposes (& also meeting compliance to some software standards) ? There are references to few inline assembly codes however they don't seem to be reliable. Are there any other ways to achieve this ?
Erich and Rong thank you for your answers, that was vinayhunsur actual question that you answered. Hopefully he sees them. My question was to vinayhunsur's "meeting compliance to some software standards". What I want to know is what are the software standards (UL1998, DO-178D etc?) that require this? Such standards are a personal interest of mine. http://www.softwaresafety.net Erich, I have used your poor man's trace in the past. Thank You for all that you document. Freescale parts of today would be useless without such examples. Sad how bad the docs have become from the Motorola days.
Hi Bob (and Xiangjun),
sorry for mixing up replies ("too many threads" could be my excuse).
About the software standards: with my experience, pretty much everything for safety critical systems or for good software quality requires some metrics (tested lines of code, code and test coverage, performance analysis and regression testing). I would say that should be commone sense today anyway.
As for the bad docs: If you could be more specific, I believe then someone else could jump in or at least take the feedback?
Thanks,
Erich
Hi Bob,
as you are using GNU/gcc, you have several options :-).
One way I would do it is to use
void
__cyg_profile_func_enter(
void
*this_fn,
void
*call_site);
void
__cyg_profile_func_exit(
void
*this_fn,
void
*call_site);
See Poor Man’s Trace: Free-of-Charge Function Entry/Exit Trace with GNU Tools | MCU on Eclipse
I'm reading and storing the program counter that way.
Another way would be to use the
__gnu_mcount_nc:
with enabled profiling. You can add there your assembly code to store the PC in your custom format if needed.
See Code Coverage for Embedded Target with Eclipse, gcc and gcov | MCU on Eclipse
Yet another way if you have either a Segger J-Link or a FRDM board with OpenSDA (and the Segger J-Link firmware on it) is to use the Segger Realtime Transfer and the Segger System Viewer. See Segger SystemView: Realtime Analysis and Visualization for FreeRTOS | MCU on Eclipse and McuOnEclipse Components: 22-Nov-2015 Release | MCU on Eclipse. There you can instrument and measure individual pieces of code, see Data Logger with tinyK20 Board | MCU on Eclipse.
I hope this gives some ideas,
Erich
I'm curious as to what standard(s)?
Hi, Bob,
If you want to assign a register value to a variable or return a register value from a subroutine, it is dependent on compiler, you have to refer to the calling convention in corresponding doc of compiler.
BR
Xiangjun Rong
Hi, Vinayhunsur,
I think you can use the following code to implement it as a basic instruction. But I suggest you use an subroutine to implement it.
I have compile the following line in KDS tools, it can compile the line successfully.
__asm("MOV R0,PC");
BR
Xiangjun Rong