 
        
        
    | 芯片: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; } | 
STM32CubeID V1.19.0 无法识别串口设备
配置CubeMX后(STM32H723VGT6),自动生成的代码,编译报错
官网注册问题
基于STM32F103的HAL库实现USB(HID) OTA升级
vscode的cubemx插件看不了livewatch
用F103的串口能跑多快?
stm32g431rbt怎么显示汉字
F103和G474的180°移相區別
STM32N6中使用AI推理的时候调用app_postprocess_init的时候程序卡死
怎么将keil工程更换为vscode工具链?
 微信公众号
                微信公众号
             手机版
                手机版
             
		
	
	
	
这个我感觉是因为中断中打印时间太长,导致定时器多次中断产生导致。或者是产生了错误,一直再进中断导致的。
[md]我加了定时器,五秒进入打印一次,一次就打印两个值,也是这个情况。