本帖最后由 WT_0213 于 2024-12-5 09:02 编辑
环境大家没啥说的,软件安装就是一顿下一步就可以了。
可以参考
【PB-03F-kit】点灯和环境配置
https://bbs.aithinker.com/forum.php?mod=viewthread&tid=45557&fromuid=16612
(出处: 物联网开发者社区-安信可论坛)
单纯点灯修改程序的话稍微有点技术含量但不多。
这里又出了一个新的知识点就是 OSAL
可以参考
【PB-03F-kit】初识OSAL操作系统
https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=45544&fromuid=16612
(出处: 物联网开发者社区-安信可论坛)
点灯
可以参考
【PB-03F-kit】程序修改+ 烧录 + 点灯
https://bbs.aithinker.com/forum.php?mod=viewthread&tid=45558&fromuid=15918
(出处: 物联网开发者社区-安信可论坛)
总体来说点灯还是比较容易的,想要玩的好不容易呢。
根据参考在gpio_demo.c
301行下面增加了如下代码
hal_gpio_write(P34,1);
魔法棒修改点击魔法棒 Options for target
弹窗选择C/C++ 标签,在Define 文本框中找到CFG_SLEEP_MPDE修改他的值,其实就是PWR_MODE_SLEEP加个 NO
C/C++具体修改如下
PWR_MODE_SLEEP 改成 PWR_MODE_NO_SLEEP
修改好代码和配置以后点下面的按钮
重新编译
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'gpio'
compiling gpio_demo.c...
compiling gpio_Main.c...
compiling my_printf.c...
compiling OSAL_gpio.c...
compiling jump_table.c...
compiling main.c...
compiling gpio.c...
assembling startup_ARMCM0.s...
compiling key.c...
compiling uart.c...
compiling clock.c...
compiling flash.c...
compiling pwrmgr.c...
compiling adc.c...
compiling system_ARMCM0.c...
linking...
Program Size: Code=23872 RO-data=1812 RW-data=1284 ZI-data=9128
FromELF: creating hex file...
After Build - User command #1: fromelf.exe --bin -o ./bin ./Objects/gpio_demo.axf
After Build - User command #2: fromelf.exe .\Objects\gpio_demo.axf --i32combined --output .\bin\gpio_demo.hex
".\Objects\gpio_demo.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:02
没有报错的话就表示修改通过了
然后就是找到hex文件进行烧录
phy6222_v313_0512\example\peripheral\gpio\Objects\gpio_demo.hex
烧录工具主要有三块区域需要注意
左侧APP双击可以选择烧录文件,这一步可以在配置UART Setting之后。
右侧分为两部分,上面个是串口设置区域、下面部分是日志区域
烧录准备:
1、勾选UART Setting复选框
2、选择Port
3、选择波特率为UXTDWU
4、点击Connect
右侧日志区域出现
Serial port COM7 closed!!
*******************************
Current port: COM7
Current baudrate: 9600
Current stopBits: 1
Current parity: No
Serial opened!!
*******************************
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
然后会一直打印,看到此信息后按下PB03开发板左侧RST按钮
UART RX: cmd>>:
Current port: COM7
Current baudrate: 115200
Current stopBits: 1
Current parity: No
Serial opened!!
*******************************
打印如上日志表示烧录状态切换成功
点击左侧Erase擦除
*******************************
Send erase successfully!
Receive #OK!
Erase successfully!
点击Write写入
=== PHY6222 ===
Receive #OK!
Reset flash successfully!
Receive #OK!
Send spif config command successfully!
Receive #OK!
Spif config successfully!
Send sfmod command successfully!
Receive #OK!
Sfmod select successfully!
Load AppHEx Done[-NO-ENC-]!
IV BLOCK GEN [-NO-ENC-]
[hexPack]: 11020000 1640
[XIP HexPack Size]: 1
[hexPack]: 1FFF0000 40c
[hexPack]: 1FFF1838 4b18
[App HexPack Size]: 2
>> BOOT========0x11002000------0x11002130========
>> APP========0x11005000------0x11009f2c========
>> XIP#0========0x11020000------0x11021640========
The App Hex file Last modified: 2024-12-04 12:01:11
[HEXF Generation] Success:
phy6222_v313_0512/example/peripheral/gpio/Objects/gpio_demo_phy6222.hexf !!!
Send cpnum successfully!
Receive #OK!
Receive >>: successful!
============Write hexf File [01/03]============
Send cpbin successfully!
UART RX ASCII: by hex mode:
Receive image request!
Send image successful! Waiting to receive checksum...
Send checksum successfully!
UART RX ASCII: checksum is: 0x0001088f#OK>>:
Receive #OK!
Receive >>: successful!
============Write hexf File [02/03]============
Send cpbin successfully!
UART RX ASCII: by hex mode:
Receive image request!
Send image successful! Waiting to receive checksum...
Send checksum successfully!
UART RX ASCII: checksum is: 0x001953bb#OK>>:
Receive #OK!
Receive >>: successful!
============Write hexf File [03/03]============
Send cpbin successfully!
UART RX ASCII: by hex mode:
Receive image request!
Send image successful! Waiting to receive checksum...
Send checksum successfully!
UART RX ASCII: checksum is: 0x00074bf9#OK>>:
Receive #OK!
Write images successfully!
Write registers successfully!
看到如上信息表示写入成功
PB03重新上电或者按下RST就可以看到点灯成功了。
注意事项,如果发现日志一直打印,按下RST尝试按久一点。或者重连一下USB线然后重新配置下UART Setting再次尝试进入烧录模式。
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
UART TX ASCII: UXTDWU
不要连续按RST按键,按一下就可以了。
在这个状态下按下RST然后会变成这样
这时如果再按一下RST设备久重启了就不能烧录了。
就会烧录失败
*******************************
UART RX : SDK Version ID 00030103
rfClk 0 rcClk 1 sysClk 2 tpCap[2f 29]
sizeof(struct ll_pkt_desc) = 8, buf size = 1876
sizeof(g_pConnectionBuffer) = 1876, sizeof(pConnContext) = 644, sizeof(largeHeap)=4096
gpio key demo start...
Send erase successfully!
Receive #OK or #ER timeout!
或者
*******************************
check ChipVersion Fail !!!
Write images failed!
又或者
UART RX : 0030103
rfClk 0 rcClk 1 sysClk 2 tpCap[2f 2b]
sizeof(struct ll_pkt_desc) = 8, buf size = 1876
sizeof(g_pConnectionBuffer) = 1876, sizeof(pConnContext) = 644, sizeof(largeHeap)=4096
gpio key demo start...
check ChipVersion Fail !!!
Load AppHEx Done[-NO-ENC-]!
IV BLOCK GEN [-NO-ENC-]
[hexPack]: 11020000 1640
[XIP HexPack Size]: 1
[hexPack]: 1FFF0000 40c
[hexPack]: 1FFF1838 4b18
[App HexPack Size]: 2
>> BOOT========0x00002100------0x0000211c========
>> APP========0x00009000------0x0000df2c========
>> XIP#0========0x00020000------0x00021640========
The App Hex file Last modified: 2024-12-04 12:01:11
[HEXF Generation] Success:
phy6222_v313_0512/example/peripheral/gpio/Objects/gpio_demo_phy6202.hexf !!!
Send cpnum successfully!
Receive feedback timeout!
Receive #OK or #ER failed!
Write images failed!
切记