0% found this document useful (0 votes)
94 views8 pages

Using The Keil Debugger Command Line: Μvision Help

The document discusses using the Keil debugger command line to create user functions and log command output to a text file for analysis. User functions in Keil follow C syntax but have limitations like not supporting arrays or pointers. The log command can be used to record variable values to a file from within a debug session. An example user function prints an integer array to the command window, and this output is logged to a file and later analyzed in Python.

Uploaded by

Ahmed Hamouda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views8 pages

Using The Keil Debugger Command Line: Μvision Help

The document discusses using the Keil debugger command line to create user functions and log command output to a text file for analysis. User functions in Keil follow C syntax but have limitations like not supporting arrays or pointers. The log command can be used to record variable values to a file from within a debug session. An example user function prints an integer array to the command window, and this output is logged to a file and later analyzed in Python.

Uploaded by

Ahmed Hamouda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Appendix

Using the Keil


Debugger B
Command Line
Introduction
Much can be said about the command line capabilities of the Keil
debugger. In this appendix I will focus on writing user functions
and using the log capability to log what is seen in the command
output display to a text file. Many other capabilities exist and
may at some point be described in this appendix.

Getting Started via μVision Help


The help system contains a vast quantity of information on all of
Keil, you just need to jump in and try to find it. For help on the
command line debugging drill down as follows:
...

...
...

Topics of
Interest
Appendix B • Using the Keil Debugger Command Line

Creating User Functions


• To create a user defined function you can use a text editor, or
more conveniently use the build-in Function Editor, which
you access from the Debug menu during a debug session:

Last menu
entry here
brings up the
editor (when
debugging)

• Debugger functions follow closely C syntax, but the language


support is limited
– For example functions cannot pass arrays or pointers
– You cannot directly read and write to a file
– You can however access all of the variables in the debug

B–2 ECE 5655/4655 Real-Time DSP


Creating User Functions

session, e.g. scalar variables and arrays


– Multiple functions can be contained in a use function file (
file extension is .ini)
• Fortunately you have access to both Debug Commands and
Debug Functions
– A very useful Debug Function is printf(), which
behaves very much like the C version
– A very useful Debug Command is log
– Note: The save command can be used to write a block of
memory to a file, but the format is Intel hex, which
requires further post processing to be used in external anal-
ysis
• Appendix A talks about the use of the serial port for sending
debug data directly to a terminal or perhaps a GUI app run-
ning on the host
• By writing a User Function you have the further option of
pre-processing any user variables and sending them to the
Command output window as result of your issuing a debug
command
– This can only be done within a debug session, but your
program may running or stopped
– Note: You can also write to variables
• Command line debug sessions can also be logged to a text
file for later analysis

ECE 5655/4655 Real-Time DSP B–3


Appendix B • Using the Keil Debugger Command Line

– log >fname //starts logging in the file fname


– log off //stops the logging
• A sample .ini file which contains two function is shown
below:
/*******************************************************
Write array contents using debug command line
********************************************************
//For int16_t buffer use:
log >fname
p_int16_buf(1000)
log off

//For float or float32_t buffer use:


log >fname
p_float_buf(1000)
log off

********************************************************
//To load these functions into the debugger workspace
(1) Run the Function editor and then compile
or
(2) At the debug command line type
include buffer_save.ini

Mark Wickert February 2015


*******************************************************/

func void p_int16_buf(int N) {


int i;
for (i=0; i< N; i++) {
//printf("The value is %d\n",buffer[i]);
printf("%d\n",buffer[i]);
}
}

func void p_float_buf(int N) {


int i;
for (i=0; i< N; i++) {
//printf("The value is %6.4f\n",buffer[i]);
printf("%6.4f\n",buffer[i]);
}
}

B–4 ECE 5655/4655 Real-Time DSP


Creating User Functions

• A summary of the steps needed to compile/include the .ini


file in your debug session is given at the top of the file
• The commands needed to create a log file of a 1000 point
int16_t variables named buffer, is also given
• A screen shot of the Command window output following the
above steps is shown below:
Start logging
Print 1000 values of the
array referenced in the
function p_int16_buf

The full listing will scroll by


in the window

• A great tool for analyzing the captured results is Python with


pylab running
• The IPython notebook provides a very nice environment for
working with the data contained in the log file and creating
post analysis plots
• A few screen shots from the available IPython notebook are
given below
– Note: The signal values held in buffer() correspond to
a 1 kHz sinusoid on the audio codec with f s = 48 ksps

ECE 5655/4655 Real-Time DSP B–5


Appendix B • Using the Keil Debugger Command Line

Make sure the notebook


is pointing to the folder
containing the data file

Compute some
stats

Plot the time


domain signal

B–6 ECE 5655/4655 Real-Time DSP


Creating User Functions

Plot the
frequency
domain as a
1 kHz spectral line as expected scaled version
of
j2πf ⁄ f s
X(e )

• The C-code set-up that fills the array buffer() is summa-


rized below:

Add globals

Fill the buffer and


wrap when full

ECE 5655/4655 Real-Time DSP B–7


Appendix B • Using the Keil Debugger Command Line

B–8 ECE 5655/4655 Real-Time DSP

You might also like