背景:
- 定义了一个数组,程序执行后维数组赋值,数组元素的值可在watchwindow显示,但无法直接保存到文件
假定程序中定义的数组为
uint32_t testarray[100];
解决方法:
1.进入debug状态,完成数组赋值
2.暂停debug
3.在µVision function editor中创建函数:(µVision function editor的打开方法为Debug->Function Editor (Open Init File))
FUNC void displayvalues(void) {
int idx;
exec("log > MyValues.log");
for (idx = 0; idx < 100; idx++) {
printf ("testarray[%d] = %u\n", idx, testarray[idx]);
}
exec("log off");
}
4.在命令行µVision command line输入
displayvalues()
5.如果一切正常,命令行窗口 command window会显示如下信息:
testarray[0] = 0
testarray[1] = 1
testarray[2] = 2
testarray[3] = 3
testarray[4] = 4
testarray[5] = 5
testarray[6] = 6
testarray[7] = 7
testarray[8] = 8
testarray[9] = 9
:
testarray[60] = 60
testarray[61] = 61
testarray[62] = 62
testarray[63] = 63
同时本地文件夹中会生成一个明为MyValues.log的文件,保存的内容与上面显示的一致
操作步骤动态图如下:
参考资料
- http://www.keil.com/support/docs/3051.htm
- http://www.keil.com/support/man/docs/uv4/uv4_df_createfunct.htm
- µVision User's Guide (arm.com)
- http://www.keil.com/support/man/docs/uv4/uv4_db_dbg_toolbox.htm