stm32 prints data to PC serial port

Publisher:转眼人老Latest update time:2017-10-31 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Generally speaking, many people use printf function redirection to achieve this, but it is not very clear.

Therefore, the sprintf function is used here to implement it.

Second, the whole idea is to put the data to be printed into the serial port send buffer of MCU to PC.

3. The sprintf function is in the stdio.h header file, so if you want to use it in the program, you must include this header file.

4. Example:


void PC_SendChar(uint8_t DataToSend)

{

RS485_TX_Enable();

USART_SendData (USART1,DataToSend);

while(USART_GetFlagStatus (USART1 ,USART_FLAG_TC )!=SET );

RS485_RX_Enable();

}

void PC_SendString(uint8_t *str)

{

while(*str)

{

PC_SendChar (*str);

str++;

}

}


char Param_Out[30];?

sprintf(Param_Out ,"The voltage of System Basic is %.5f V\r\n",System_Basic_Vol);

PC_SendString((u8*)Param_Out );


Keywords:stm32 Reference address:stm32 prints data to PC serial port

Previous article:The role of bootloader and startup_stm32f10x_md.s in stm32
Next article:How to send characters and strings using stm32's USART

Recommended ReadingLatest update time:2024-11-16 13:23

STM32 learning: the simplest GPIO operation steps
The ".c" library functions needed are stm32f10x_gpio.c and stm32f10x_rcc.c   1. Start the RCC (reset always control) of the corresponding Port x     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx, ENABLE);     x can be A to G, GPIO is controlled by APB2 (high-speed peripheral) clock 2. Assign values ​​to the three parame
[Microcontroller]
Programming and implementation of a simple oscilloscope based on STM32 built-in ADC
  Making a digital sampling oscilloscope has been my long-standing wish, but after all, this goal is quite difficult, and there are too many aspects involved, such as analog front-end circuit, high-speed ADC, microcontroller, CPLD/FPGA, communication, host computer program, data processing, etc. It is not something th
[Test Measurement]
Programming and implementation of a simple oscilloscope based on STM32 built-in ADC
Definition of STM32 CPU ID, Unique ID, Flash size register
Note that CPU ID and Unique ID have different definitions for ST. The CPU ID is built-in to CortexM3, and the reset value is consistent. There are definitions in PM0056.pdf. Unique ID is a different ID for each chip, which is defined in RM0008.PDF. For example, F103 is defined in Section 30.2. Flash size register is
[Microcontroller]
BMP180 test based on STM32 platform (simulated IIC)
1. Test description: Use analog IIC to get the ID number, temperature, pressure and altitude from BMP180. 2. Test preparation: Hardware platform: Atomic Battleship V3 development board  Test tools: logic analyzer, serial port debugging tool 3. Data sheet interpretation: (1) First is the timing diagram of reading m
[Microcontroller]
BMP180 test based on STM32 platform (simulated IIC)
stm32 EXTI interrupt BUG, ​​unable to enter external interrupt problem
When I was debugging a program, I found that there was an EXTI interrupt that I could not enter no matter what. Although I checked various experiences on the Internet, none of them helped my program. Later, I finally found the problem. The reason was that there were some problems with the official library function.  T
[Microcontroller]
STM32 MCU (8) Program encryption
References http://www.cnblogs.com/pied/archive/2011/06/08/2075481.html http://v.pps.tv/play_38DQ4J.html#vfrm=8-8-0-1 related articles Serial port interrupt communication  http://blog.csdn.net/leytton/article/details/38393553 Serial communication printf redirection  http://blog.csdn.net/leytton/article/details/3839
[Microcontroller]
STM32 library function configuration
In versions above stm32  firmware library V3.0, source files such as main no longer directly contain stm32f10x_conf.h, but stm32f10x.h. stm32f10x.h defines the startup settings and all register macro definitions. The following points should be noted in this file: The method of using the firmware library of versio
[Microcontroller]
STM32 library function configuration
STM32's five new products are launched, and heavy investment is made to actively expand production capacity!
After a long epidemic, ST held its first press conference in Beijing this year, launching a number of products, covering the full range of products in the STM32 product family. "These product launches represent ST entering a new era - the era of cloud connectivity and intelligent edge," said Julian, vice
[Microcontroller]
STM32's five new products are launched, and heavy investment is made to actively expand production capacity!
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号