锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

HC32F120开发之printf()

时间:2022-09-06 23:00:00 dd70f120三社二极管模块

HC32 DDL库与集成printf()相关的uart初始化函数和fputc(int32_t ch, FILE *f)函数,只需要在ddl_config.h宏定义将在文件中定义DDL_PRINT_ENABLE定义为DDL_ON就行:

#define DDL_PRINT_ENABLE                            (DDL_ON)

DDL_PrintfInit()和fputc(int32_t ch, FILE *f)函数的代码在hc32f120_utility.c在文件中,关联uart为uart1,GPIO管脚为P12。

使用方法

在main()函数初始化部分的调用DDL_PrintfInit()函数,需要打印日志的地方调用DDL_Printf()或printf()即可:

/**  * @brief  Main function of template project  * @param  None  * @retval int32_t return value, if needed  */ int32_t main(void) {     /* Add your code here */   DDL_PrintfInit();     printf("hello world!\n");    while (1)  {         ;  } }

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章