背景:
- 定義了一個數組,程序執行後維數組賦值,數組元素的值可在watchwindow顯示,但無法直接保存到文件
假定程序中定義的數組爲
uint32_t char 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的文件,保存的內容與上面顯示的一致
操作步驟動態圖如下:
參考資料