I recently wrote an STM32 program and used a union, which caused a question.
For example, 0x12345678 is stored in a U32 type variable. The big endian and little endian are stored like this.
Big-endian storage: Low address ... High address 0x 12 34 56 78 Little endian storage: Low address ... High address 0x 78 56 34 121234567
See the code
`#include "stm32f10x.h"
struct s
{
u32 a;
u8 b;
};
union B
{
u8 c[5];
struct s s_1;
};
union B BB;
int main(void)
{
BB.s_1.a=0x12345678;
BB.s_1.b=0x09;
while(1);
}`
Output:
It can be seen that the storage format is little-endian.
Be sure to pay attention when writing code in the future.
Previous article:STM32 error, error status and solution
Next article:STM32 uses SWD to connect and report errors
- Popular Resources
- Popular amplifiers
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Will it damage the phone or battery if I play games while charging my phone after it is fully charged?
- [NXP Rapid IoT Review] + Experience of using Rapid IOT Studio
- My goodness, what kind of electronic component is this?
- The sequel is here! Is it okay to have no reference? Let me explain it all at once!
- esp32
- Anti-interference problem of ws2812b light strip
- Showing products + recording my development journey
- Practical information delivery: Digital power technology literacy
- Keil errors and warnings
- [Evaluation of EC-01F-Kit, the NB-IoT development board of Anxinke] - Unboxing and comparison with other modules