STM32嵌入式应用系统设计
一、三种工具的选用
1、可视化前端 Kdbg
(1)、安装Kdbg
sudo apt-get install kdbg
或
git clone -b maint https://github.com/j6t/kdbg.git
//如果没有git需要先执行一下
sudo apt-get install git
(2)、安装两个依赖库
1、Qt5.4版本
开始下载:qt-opensource-linux-x64-5.9.0.run
下载好复制到虚拟机内再执行以下命令,然后双击文件就可以安装了
chmod +x qt-opensource-linux-x64-5.9.0.run
2、KF5
sudo apt install extra-cmake-modules qtbase5-dev libx11-dev libkf5crash-dev libkf5kio-dev libkf5solid-dev libkf5jobwidgets-dev libkf5textwidgets-dev libkf5bookmarks-dev libkf5xmlgui-dev libkf5itemviews-dev libkf5attica-dev libkf5sonnet-dev libkf5globalaccel-dev libkf5guiaddons-dev libkf5codecs-dev libkf5auth-dev libkf5dbusaddons-dev libkf5coreaddons-dev libkf5iconthemes-dev libkf5configwidgets-dev libkf5widgetsaddons-dev libkf5service-dev libkf5config-dev libkf5windowsystem-dev libqt5concurrent5 libpulse-dev libqt5x11extras5 libqt5x11extras5-dev
3、cmake一下
cmake .
4、编译一下
make
sudo make install
5、输入kdbg就可以运行了
kdbg
2、可视化前端 Insight
(1)、参考链接
https://wiki.ubuntu.org.cn/Insight%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%EF%BC%88gdb%E7%9A%84%E6%9C%80%E4%BC%98%E5%89%8D%E7%AB%AF%EF%BC%89
3、基于跨平台多类型代码编辑器VScode
(1)、安装
1、点击应用中心
2、搜索Visual Studio Code
3、选择install
4、
修改launch.json和task.json
修改后的tasks.json和launch.json
1)tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
2)launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
4.配置好后我们就可以先按ctrl+shift+B先编译,然后再按绿色箭头调试了
二、Proteus仿真运行stm32程序
1、在keil5中编写main.c程序并执行生成.hex文件
#include "stm32f10x.h"
GPIO_InitTypeDef GPIO_InitStructure;
void delay_ms(uint32_t ms)
{
uint32_t i_cnt,j_cnt;
for(i_cnt=0;i_cnt<3000;i_cnt++);
for(j_cnt=0;j_cnt<ms;j_cnt++);
}
uint32_t i;
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIOC->BSRR=0xff;
while (1)
{
for(i=0;i<8;i++)
{
delay_ms(99000);
GPIOC->BRR=(1<<i);
delay_ms(99000);
GPIOC->BSRR=(1<<i);
}
for(i=0;i<8;i++)
{
delay_ms(99000);
GPIOC->BRR=0x000000ff;
delay_ms(99000);
GPIOC->BSRR=0x000000ff;
}
}
}
2、在Proteus绘制仿真线路图,并导入.hex文件
3、运行结果
三. 学习使用Altium Designer软件绘制一个stm32最小系统的电路原理图、PCB图。
参考学习网站:
https://www.bilibili.com/video/BV1Ab411K7yp/?spm_id_from=333.788.videocard.0
https://www.bilibili.com/video/BV17E411x7dR?p=2
Altium Designer 1小时(貌似不够)速成