z@z-ThinkPad-X61:~/zworkingCopy/mcu/F030$ cat simplest_uart_Tx.cmd
#必须注意:openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f0x_stlink.cfg -c init -c halt
# 不能用reset,必须是halt
#芯片复位
echo reset halt | nc localhost 4444
#开PA clk
echo mww 0x40021014 0x20014 | nc localhost 4444
#开串口时钟
echo mww 0x40021018 0x4000 | nc localhost 4444
#PA辅助功能, 高28是swio, swclk接口的辅助功能,而剩下两个是pa9/10的TXRX功能辅助。
#echo mww 0x48000000 0x28240000 | nc localhost 4444
echo mww 0x48000000 0x28280000 | nc localhost 4444
#将PA9,PA10设置成AF1
echo mww 0x48000024 0x110 | nc localhost 4444
#reset串口
echo mww 0x4002100c 0x4000 | nc localhost 4444
echo mww 0x4002100c 0x0 | nc localhost 4444
#set baud 115200
echo mww 0x4001380c 0x45 | nc localhost 4444
#read status
echo mdw 0x4001381c 1 | nc localhost 4444
# 收发使能
echo mww 0x40013800 0xd | nc localhost 4444
#read status
echo mdw 0x4001381c 1 | nc localhost 4444
# send 发
echo mww 0x40013828 0x5a | nc localhost 4444
#读取状态
echo mdw 0x4001381c 1 | nc localhost 4444
#再发再看
echo mww 0x40013828 0xb4 | nc localhost 4444
echo mdw 0x4001381c 1 | nc localhost 4444
#读TXDR,确认是0xb4即最后一次发的功能
echo mdw 0x40013828 1 | nc localhost 4444
#PC一发,读取RXDR,就看到了:
#echo mdw 0x40013824 1 | nc localhost 4444
z@z-ThinkPad-X61:~/zworkingCopy/mcu/F030$
z@z-ThinkPad-X61:~/zworkingCopy/mcu/F030$
z@z-ThinkPad-X61:~/zworkingCopy/mcu/F030$ cat simplest_uart_PCsend_RxRead.cmd
# 必须先跑,另一个脚本,才能跑这个:
seq 9 | xargs -i bash -c "echo {}; echo -n {} | nc localhost 4161; echo mdw 0x40013824 1 | nc localhost 4444; "
网友评论