# 关于 基于 STM32CubeMX 的 HAL 库 通过 VScode 开发 STM32 工程文件内容的配置及更改
- 新添加 C 文件后需要在 Makefile 文件中 # C sources 下添加上 C 文件的文件路径
- 更换芯片时,在对应的 c_cpp_properties.json 和 tasks.json 中对芯片相关的型号数据进行更改
1. 启动调试下载器指令
- 已配置在 tasks.json 文件中
- 更改芯片时同时将指令末的 stm32f1x.cfg 进行更改
`openocd -f interface/cmsis-dap.cfg -c 'transport select swd' -f target/stm32f1x.cfg`
2. 查看 OpenOCD 所支持的下载器型号,并可以对应自己的下载器进行更改
- D:\OpenOCD\OpenOCD-20200701-0.10.0\share\openocd\scripts\interface
3. 查看 OpenOCD 所支持的芯片型号,并可以对应选择芯片相应的型号
- D:\OpenOCD\OpenOCD-20200701-0.10.0\share\openocd\scripts\target
4. STM32 开发中串口通讯的 `printf` 重定义
- 字符串结尾加\r\n
- 为使用`printf`函数添加 `#include <stdio.h>` 头文件
```C
/****可以在串口使用printf打印****/
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf set to 'Yes') call __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
//具体哪个串口可以更改huart1为其它串口
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xffff);
return ch;
}
//keil中无需此函数
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
/****可以在串口使用printf打印****/
```
5. 串口使用`printf`打印浮点数`float`问题
- 支持 float makefile 在 Makefile 中的 # libraries 下加上-u_printf_float
- Makrfile 中的 # libraries 下更改
```makefile
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
LDFLAGS = $(MCU) -specs=nano.specs -u_printf_float -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
SHT31温湿度.zip (255个子文件)
SHT31.axf 595KB
SHT31.bin 24KB
stm32f1xx_hal_i2c.c 234KB
stm32f1xx_hal_tim.c 213KB
stm32f1xx_hal_uart.c 110KB
stm32f1xx_hal_tim_ex.c 64KB
stm32f1xx_hal_rcc.c 49KB
stm32f1xx_hal_flash_ex.c 36KB
stm32f1xx_hal_rcc_ex.c 30KB
stm32f1xx_hal_flash.c 30KB
stm32f1xx_hal_dma.c 28KB
stm32f1xx_hal_pwr.c 21KB
stm32f1xx_hal_gpio.c 21KB
stm32f1xx_hal.c 20KB
stm32f1xx_hal_cortex.c 19KB
stm32f1xx_hal_exti.c 15KB
system_stm32f1xx.c 15KB
OLED.c 11KB
stm32f1xx_it.c 6KB
main.c 5KB
stm32f1xx_hal_gpio_ex.c 4KB
usart.c 4KB
i2c.c 3KB
myiic.c 3KB
gpio.c 3KB
stm32f1xx_hal_msp.c 2KB
SHT31.c 2KB
stm32f1xx_hal_i2c.crf 551KB
stm32f1xx_hal_uart.crf 508KB
stm32f1xx_hal_dma.crf 503KB
stm32f1xx_hal_rcc.crf 503KB
stm32f1xx_hal_flash_ex.crf 496KB
main.crf 496KB
stm32f1xx_hal_flash.crf 495KB
sht31.crf 495KB
usart.crf 495KB
stm32f1xx_hal_gpio.crf 494KB
stm32f1xx_hal_exti.crf 494KB
oled.crf 493KB
stm32f1xx_hal_pwr.crf 493KB
stm32f1xx_hal_rcc_ex.crf 493KB
stm32f1xx_hal.crf 492KB
i2c.crf 492KB
gpio.crf 492KB
stm32f1xx_hal_cortex.crf 491KB
stm32f1xx_it.crf 491KB
system_stm32f1xx.crf 491KB
stm32f1xx_hal_msp.crf 491KB
stm32f1xx_hal_gpio_ex.crf 491KB
stm32f1xx_hal_tim_ex.crf 490KB
stm32f1xx_hal_tim.crf 490KB
main.d 3KB
OLED.d 3KB
SHT31.d 3KB
stm32f1xx_it.d 3KB
stm32f1xx_hal_flash_ex.d 3KB
stm32f1xx_hal_gpio_ex.d 3KB
stm32f1xx_hal_rcc_ex.d 3KB
stm32f1xx_hal_tim_ex.d 3KB
stm32f1xx_hal_cortex.d 3KB
stm32f1xx_hal_flash.d 3KB
stm32f1xx_hal_gpio.d 3KB
stm32f1xx_hal_uart.d 3KB
stm32f1xx_hal_exti.d 3KB
stm32f1xx_hal_rcc.d 3KB
stm32f1xx_hal_dma.d 3KB
stm32f1xx_hal_pwr.d 3KB
stm32f1xx_hal_i2c.d 3KB
stm32f1xx_hal_tim.d 3KB
usart.d 3KB
stm32f1xx_hal_msp.d 3KB
gpio.d 3KB
i2c.d 2KB
stm32f1xx_hal.d 2KB
system_stm32f1xx.d 2KB
stm32f1xx_hal_flash_ex.d 2KB
stm32f1xx_hal_gpio_ex.d 2KB
stm32f1xx_hal_cortex.d 2KB
stm32f1xx_hal_tim_ex.d 2KB
stm32f1xx_hal_rcc_ex.d 2KB
stm32f1xx_hal_flash.d 2KB
stm32f1xx_hal_uart.d 2KB
stm32f1xx_hal_gpio.d 2KB
stm32f1xx_hal_exti.d 2KB
stm32f1xx_hal_msp.d 2KB
stm32f1xx_hal_dma.d 2KB
stm32f1xx_hal_i2c.d 2KB
stm32f1xx_hal_tim.d 2KB
stm32f1xx_hal_rcc.d 2KB
stm32f1xx_hal_pwr.d 2KB
system_stm32f1xx.d 2KB
stm32f1xx_it.d 2KB
stm32f1xx_hal.d 2KB
main.d 2KB
sht31.d 2KB
oled.d 2KB
usart.d 2KB
gpio.d 2KB
i2c.d 2KB
startup_stm32f103xe.d 52B
共 255 条
- 1
- 2
- 3
_Jarvis^
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 《认识计算机桌面》教案.doc
- 《软件工程》期末考试参考题及答案.doc
- 《软件工程》期末考试及答案.doc
- 《软件工程》经典考试例题复习试题-重点知识点(含答案)(良心出品必属精品).doc
- 《软件工程》经典考试例题复习题-重点知识点(含答案)(良心出品必属精品).docx
- 《软件工程》考试及答案A卷B卷.doc
- python-ldap-3.4.4-cp311-cp311-win-amd64.whl
- 【推荐】logistic分析(可编辑修改).ppt
- 基于opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明(高分项目).zip
- 使用Python调用微信本地ocr服务.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0