串口调试--STM32里的printf

配置串口调试,可以更好的进行调试
在usart.c文件的末尾添加如下代码

#include<stdio.h>
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
    if(GPIO_Pin == Key1_Pin)
    {   
        printf("this is exti!!\r\n");
         HAL_Delay(10);
        if(HAL_GPIO_ReadPin(Key1_GPIO_Port,Key1_Pin)==0)
        {
                printf("this is exti\r\n");
        }
    }
}

通过在程序中添加printf,就可以在串口工具里看到调试信息
。。。换行使用\r\n。

猜你喜欢

转载自blog.csdn.net/qq_42425882/article/details/89053092