使用场景: (1) 使用者没有客户的程序代码,但需要针对客户的项目进行除错 (2) 使用者没有客户的开发环境( KEIL μVision or IAR EWARM ),但须要针对客户的项目进行除错
1. 建立一个 lua 档案. (Lua Example 1) 2. 开启 PinView 3. 执行 lua 脚本 4. PinView 右侧窗口会显示改变的内容 Lua Example 1: my1.lua – 存取 GPIOA 寄存器并切换I/O逻辑 -- Config local write_data = 0 local RegAdd = 0x50004008 -- GPIOA_DOUT -- Print setting local ext = require("ext") local print = ext.redirect_print print(string.format('Hello Nuvoton')); -- Read register local read_data = ice:ReadMem32(RegAdd) print(string.format("ReadMem: addr 0x%08X, data 0x%08X", RegAdd, read_data)) -- Write register write_data = 0xFFFF-read_data; -- Invert GPIOA data ice:WriteMem32(RegAdd, write_data) print(string.format("WriteMem addr 0x%08X, data 0x%08X", RegAdd, write_data)) Lua Example 2: my.lua – 打印 SRAM 资料 -- Config local RegAdd = 0x20000000 -- SRAM address local total_size = 256 -- Data length -- Print setting local ext = require("ext") local print = ext.redirect_print print(string.format('Hello Nuvoton')); -- Dump SRAM data local i = 0 while i < total_size do local read_data = ice:ReadMem32(RegAdd+i) print(string.format("ReadMem: addr 0x%08X, data 0x%08X", RegAdd+i, read_data)) i = i + 4 end
|