"Code Generation" of MDK (keil) project properties. Add Printf1, include 2, and add" />

Application of printf function in STM32 compiler keil

Publisher:快乐的成长Latest update time:2018-12-12 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

First, please check "UseMicroLIB" in "Target"->"Code Generation" of MDK (keil) project properties.


Add Printf to your program


1,#include


2. Add


#ifdef __GNUC__


#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

#else

#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)

#endif



PUTCHAR_PROTOTYPE

{


USART_SendData(USART1, (uint8_t) ch);



while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)

{}


return ch;

}


3.


Add in Main()


USART_Configuration()


transfer


printf("The is an example!" );


Output functions like


Keywords:STM32 Reference address:Application of printf function in STM32 compiler keil

Previous article:STM32L series MDK5 debugging
Next article:Cannot set breakpoints when using ST-LINK to debug the STM32 microcontroller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号