We all know that the unit of transmission of the microcontroller serial port is byte, and the floating point number occupies four bytes. The simple idea is to use a char pointer to point to the floating point data, and use the pointer addressing to split the floating point number into four char data. The receiving end receives four char numbers. In order to restore them to float data, using a union is a good way. The test code is as follows:
The program running results are as follows:
Note: If you use signed character data in the structure, there will be some problems when printing with printf. You can try it.
Of course, there is also the big-endian and small-endian problem that is often mentioned in embedded systems. I believe everyone understands what is going on.
Previous article:Commonly used IO port levels
Next article:Processing of float data in serial communication
Recommended ReadingLatest update time:2024-11-15 13:40
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- RF quality information sharing
- LSM6DSL acceleration wake-up threshold usage (WAKE_UP_THS (5Bh))
- NUCLEO Burning
- New Year, gifts, and heights are all here! AMS OSRAM invites you to play games and win New Year gifts!
- Seven Rules for Measuring Oscilloscope Noise
- "Recommend Chinese chips" + domestic FPGA
- [Rawpixel RVB2601 Creative Application Development] Running Routine HELLOWORLD
- EEWORLD University ---- Microwave Technology Basics
- How to deploy and install docker service on arm platform
- Solar photovoltaic grid-connected power generation and its inverter control