51 MCU engineers share their own arm development experience

I came across many friends discussing in the forum about electrical engineering design: "How do you learn to learn?" In this article, Xiaobian has found an engineer who works in single-chip and embedded system applications, and he shares his practical experiences.

2.png

I used to work with 51 microcontrollers, but only with C51. I have over 10 years of experience in C programming, but I didn't use it much. Later, I switched to ARM due to a project. At first, I knew nothing about ARM. I read a book called "ARM Architecture and Programming," but I was still confused. However, maybe because I was ignorant, I just created a project in MDK, added the built-in startup file, and wrote a main function that ran in an infinite loop without touching any hardware. To my surprise, it actually worked. Then, based on that foundation, I slowly started controlling GPIOs and serial communication. It suddenly dawned on me that I wasn’t doing anything too complicated—what were those other operating modes, link registers, or PC registers? I didn’t care. All I needed was to control the peripherals. How they were implemented was up to the compiler and linker.

Looking back now, developing for ARM seems quite simple. Especially if you're using MDK, you can get started with some basic development easily. Don’t be confused by all those strange concepts. Learn while you develop, and as your projects become more complex, everything will gradually make sense. Our company has a new employee, and when I ask him to do something simple like buttons or serial ports, he almost always gets it done quickly.

After talking for a while, Luo Wei gave a few suggestions:

1. You don’t need to be proficient in ARM assembly. Just understand it enough to read it when debugging. If you’re working on high-speed applications and need to use assembly, I think what you really need is to change your mindset and optimize your algorithm. For example, replace calculations with lookup tables. I’ve been working with ARM for five years, completed over ten projects, and haven’t written a single line of assembly yet.

2. Because of real-time and cost constraints in industrial control, I usually avoid using an operating system. Instead, I implement memory management, event handling, mailboxes, and similar features. These take time to accumulate, so I always try to write general-purpose code and build my own library. Once you start using it, it feels pretty cool. I've used some OS before, but I found that it didn’t speed up my development and even caused debugging issues. I couldn’t track down bugs easily.

3. For companies, if a project requires an OS, networking, GUI, or file system, it's better to buy a ready-made board. Everything is already done, and there are very few bugs. That’s fine. If you need a large quantity, you can customize it and calculate the development cost—it might end up being cheaper. If you're personally interested, then go for it. I wouldn’t stop you.

4. There are now pre-built libraries for peripherals. I suggest you either avoid them or use them sparingly. To use these libraries well, you must understand the peripheral registers. At that point, writing your own code is often simpler. A basic register assignment is usually sufficient, and a function library may require calling multiple functions, which can be overkill. However, for computational libraries like DSP, it's better to use them since they're optimized and efficient.

5. Use interrupts whenever possible. This applies to both 51 and ARM. There’s absolutely no need to poll for events where interrupts can be used. Interrupts are the soul of a microcontroller, and all your programs should revolve around them.

6. Learn C well, and develop your own coding style. Start with clear function and variable names, and write more comments. Don’t be afraid of being thorough—these are essential. I believe the best code style is one where you can immediately understand what the program does without reading comments. The code itself should act as the comment. Sometimes I write things like `a = b - 2 - 1`, not because it's silly, but because 2 and 1 represent different values. Writing `3` directly would make it harder to understand, and it doesn’t affect performance—the compiler will optimize it to `a = b - 3`.

7. For C programmers, mastering pointers is crucial. If interrupts are the soul of a microcontroller, then pointers are the soul of C.

In short, working with ARM is almost the same as working with 51. The key is understanding how to operate the various peripheral registers.

Band BC 5000

Band BC 5000,Band Vape, Band BC 5000Puffs,Band BC 5000 Puff

YIWU JUHE TRADING COMPANY , https://www.nx-vapes.com