
芯片:STM32F103C8T6 环境:STM32CubeMX和STM32CubeIDE 库:STM32F1HAL 问题:UART1 printf打印浮点数,偶尔出现数据丢失,其他时间正常打印 固定实数,局部变量float A=25.6666;float B=24.7777; 使用调试器来逐步执行代码,调用printf之前和之后的变量值都是A=25.6666; B=24.7777; 实际打印出来: 第一种情况:A=2.0000;B=0.0000; 第二种情况:A=-2.0000; B=-26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.000000 偶尔会出现以上情况,除此之外正常打印浮点数。 以下是重定向printf的代码 UART_HandleTypeDef UartHandle; ifdef GNUC/* With GCC, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() */ define PUTCHAR_PROTOTYPE int __io_putchar(int ch)elsedefine PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)endif / GNUC /PUTCHAR_PROTOTYPE { / Place your implementation of fputc here / / e.g. write a character to the USART1 and Loop until the end of transmission / HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF); return ch; } |
最近在学习使用VS code软件+MX配合开发
STM32F1使用FSMC外扩SRAM数据读写高8位数据异常问题
STM32CubeIDE 2.0开发下载了吗
新版STM32CubeIDE会不会提供Deepseek
STM32CubeIDE支持第三方插件了吗
STM32CubeIDE 2.0版本大概什么时候上线
stm32h750xbh6程序运行在外部qspi flash中为什么lwip读取的数据和发送方的不一样?
STM32H755生成的stm32CubeIde的TouchGFX designer生成代码出错。
STM32H755的TouchGFX不能选择M7内核
STM32H755的TouchGFX如何使能Cortex-M7
这个我感觉是因为中断中打印时间太长,导致定时器多次中断产生导致。或者是产生了错误,一直再进中断导致的。
[md]我加了定时器,五秒进入打印一次,一次就打印两个值,也是这个情况。