Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Five tips for embedded beginners to know-experience

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

For many students who are about to graduate and the low-level technicians who are working hard in society, they are confused about the development of embedded systems and the level of technology they have mastered. They don't know how to learn. In fact, mastering embedded learning is not as difficult as imagined, and there are tricks for learning it. Here, if you want to learn but have no direction to leave the penguins, say no more, today to share some practical information, bring a few tips:

1. Use design patterns

A design pattern is a solution used to deal with problems that are repeated in the software. The developer can choose to waste valuable time and budget to reinvent a solution from scratch, or he can choose the best solution from his solution toolbox to solve the problem. At the beginning of the advent of microprocessors, the underlying drivers are already mature, so why not take advantage of existing mature solutions?

Driver design patterns fall roughly into the following four categories: Bit bang, polling, interrupt drive, and direct memory access (DMA).

Bit bang mode: when the microcontroller has no peripherals to perform functions, or when all peripherals have been used and there is a new request, then the developer should choose the Bit bang design pattern. The solution of the Bit bang pattern is very efficient, but it usually requires a lot of software overhead to ensure its implementation ability. The Bit bang mode allows developers to manually complete communication protocols or external behaviors.

The polling mode is used to simply monitor events in a polling scheduling mode. The polling mode is suitable for very simple systems, but many modern applications require interrupts.

Interrupts allow developers to handle events when they occur without having to wait for the code to check manually.

The DMA (Direct memory access) mode allows other peripherals to handle the need for data transfer without driver intervention.

two。 Understand real-time behavior

Whether a real-time system can meet the real-time requirements depends on its driver. Drivers with poor writing capabilities are inefficient and may cause unwitting developers to give up the performance of the system. The designer needs to consider two characteristics of the driver: blocking and non-blocking. A blocked driver prevents any other software from performing operations until it finishes its work. For example, a USART driver can load a character into the transmission buffer and wait until the end of transmission flag is received before proceeding to the next step.

On the other hand, the non-blocking driver generally uses interrupts to realize its function. The use of interrupts prevents drivers from intercepting the execution of other software while waiting for an event to occur. The USART driver can load a character into the transfer buffer and wait for the main program to issue the next instruction. The setting of the transmission end marker will cause the interrupt to end, allowing the driver to proceed to the next step.

Either way, in order to maintain real-time performance and prevent failures in the system, developers must understand the average execution time of the driver and the worst-case execution time. A complete system may cause greater security problems because of a potential risk.

Reuse design

Why recreate the wheel when time and budget are tight? In driver development, reuse, portability and maintainability are the key requirements of driver design. Many of these features can be explained by the design and use of the hardware abstraction layer.

The hardware abstraction layer (HAL) provides developers with a way to create a standard interface to control the peripherals of the microcontroller. Abstractions hide implementation details and instead provide visualization features such as Usart_Init and Usart_Transmit. This approach is to make any USART, SPI, PWM or other peripherals have the common features that all microcontrollers support. Use HAL to hide the underlying, device-specific details, allowing application developers to focus on the application's requirements rather than on how the underlying hardware works. At the same time, HAL provides a reuse container.

4. Reference data manual

Microcontrollers have become more and more complex in the past few years. In the past, to fully understand a microcontroller, you needed to master a single data manual consisting of about 500 pages. Today, a 32-bit microcontroller usually consists of a partial data manual, a data sheet for the entire series of microcontrollers, hundreds of data for each peripheral, and a data manual for all errata. Developers need to know thousands of pages of files if they want to fully grasp this part of the content.

Unfortunately, all of these data manuals are what a driver really needs. The developer collects and sorts the information contained in each data manual from the beginning. Usually each of them needs to be accessed to get the peripherals up and running. Key information is scattered (or hidden) in each type of data manual.

5. Beware of peripheral failure

Recently, I happened to have the opportunity to port a series of microcontroller drivers to other microprocessors. Both the manufacturer and the data manual show that PWM peripherals are the same between the two series of microcontrollers. However, the reality is that there is a big difference between the two when running the PWM drive. The driver can only work on the original microcontroller, but not on the new series of microcontrollers.

After flipping through the data manual over and over again, I found in a completely irrelevant footnote in the data manual that the PWM peripheral would be in a fault state when powered on and needed to clear a flag bit hidden in the register. At the beginning of the driver implementation, confirm the possible failure of the peripheral and look for other seemingly unrelated register errors.

The above 5 points hope to help you learn embedded, of course, if you still do not understand, it does not matter, everyone has this time. You can stay here. Goose. I have also saved a lot of practical information over the years. I believe it will help you study better, so please climb another high-rise building.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report