1. Include header files
#include "stdio.h"
2. Redefine the serial port
int fputc( int ch, FILE * f) { while ((USART1->SR & 0X40 ) == 0 ); // Send in a loop until the sending is complete USART1->DR = (uint8_t) ch; return ch; }
3. If only the first two steps are completed, the emulator can be used to run, but the program cannot run by itself. Also add the following code
#pragma import(__use_no_semihosting) void _sys_exit(int x) { x = x; } struct __FILE { int handle; /* Whatever you require here. If the only file you are using is */ /* standard output using printf() for debugging, no file handling */ /* is required. */ }; FILE __stdout; /* FILE is typedef’ d in stdio.h. */
This setting can avoid using the LIB library
Read More:
- torch.max Example (How to Use)
- Electron: How to Use BrowserWindow to Create a Window
- Jquery use queue to implement Ajax request queue Simple Example
- Android: How to Add Background Music for Activity with Service
- Windows Core Audio APIs: How to Progress Loopback Recording and Generate WAV File
- Docker: How to build a rabbitmq image cluster
- C#: How to Get details of the directory where the currently running program is located
- Canvas: How to Implement Video Screenshot Function
- Android: How to get the size of font you set (Example Code)
- Python: How to Create List by Comprehension (Example Codes)
- go sync.Mutex Lock Examples
- File class details (get the file name, size, path, create, etc.)
- Opentelemetry + Jaeger Python Version Cross Service Call Example
- Flutter & Dart Regular Expression Examples
- Flutter & Dart every() Method Example
- Hutool Excel Import & Export Example
- Flutter & Dart Enumeration Example
- Base64 Image Compression Example
- Websocket Front-end Call Example
- Matplotlib Draw 3D scatter Diagram Example