Using better devices only creates a good foundation and possibility for designing and implementing a good system. If you still use and follow the traditional hardware and software design ideas and methods, you can't use AVR well, and you can't even really understand the characteristics and strengths of AVR.
AVR has the characteristics of quick start and easy development, but to fully appreciate and give full play to the advantages of AVR, it also requires the application engineer's own hardware and software design and development capabilities to continue to learn and practice.
Compared with traditional types of single-chip microcomputers, AVR has greatly improved and improved in many aspects such as structural system, functional components, performance and reliability, in addition to being able to realize some of the original basic functions.
The better the function of the device, the more people with higher skills and abilities are needed to use and drive it. Just like a good F1 racing car, only a driver with superb skills can fully appreciate the characteristics of the car and maximize its performance.
"Outsiders watch the excitement, insiders watch the doorway", for engineers with a certain foundation in embedded and single-chip system design and development, it is a good idea to try AVR first.
Development environment and tools: PC + download line + actual system board
Development software on PC:
AVR Studio (Free) assembly + assembly debugging + high-level language debugging + software simulation
ICC, CVAVR, BASCOM-AVR high-level language program development + program download. One of them is purchased as a genuine full-function as the main development environment, and the other uses the DEMO version as an auxiliary and reference.
AVR ISP download line:
STK200 and STK200+ and STK300 ISP programmer. Through the printer port of the PC, the system running code (HEX, BIN) and data are written into the Flash and EEPROM of the AVR chip using ISP technology to program the configuration fuse bit and encryption bit of the AVR. Supports most AVR chips, as well as ATMEL's 51-compatible chips 89S8252, 89S52, etc. The download line support program is included in ICC, CVAVR, BASCOM-AVR, and BASCOM-8051. Free dedicated download programs: SLISP, PonyProg2000, etc.
Recommendations for not using emulators as much as possible:
When developing and debugging system programs, many people rely entirely on emulators, and once they leave the emulator, they feel at a loss. In fact, since the AVR's Flash memory can be easily erased and written online multiple times using ISP technology, it is recommended to try not to use (rely on) emulators to develop and debug programs.
In the actual development process, program debugging can start from the following aspects:
Current high-level language compilers (such as C compilers) can generate highly efficient machine codes, so it is recommended that you try to use high-level languages to write system programs.
Use the AVR Studio software simulation environment provided by Atmel, as well as other software simulation environments (BASCOM-AVR).
Use high-level languages to write system programs as much as possible.
Utilize the LED, LCD or asynchronous serial port on the target board. See the introduction of "How to develop AVR without an emulator" in the attachment.
Improve the rationality of hardware design:
Try to reasonably and fully use the resources in the AVR chip, such as EEPROM, A/D, and internal RC oscillator source.
Try to use peripheral devices connected by serial communication, large-capacity memory, LCD controller, printer, and use 7279 instead of 8279 (LED digital tube + keyboard). Except for the need to expand RAM (such as voice and image), it is generally not recommended to use parallel expansion (573 + decoding circuit) to reduce the probability of hardware, wiring and PCB board errors, and also improve the reliability of the system. Parallel expansion to serial expansion is a development trend. Now there are a large number of new peripheral devices using high-speed serial interfaces, such as A/D, D/A, RTC, memory, etc.
Try to use and reserve the ISP program download interface on the target board, or use IAP technology.
Advantages: The compatibility of ISP interface and I/O is better than JETAG.
Disadvantages: Cannot debug online
Pay attention to and master the use of AVR configuration fuses:
. System crystal selection.
Use of BOD
. Startup delay. PC6 pin of Mega8, conversion between RESET and general I/O.
Conversion between JETAG interface and general I/O
. Conversion of startup vector, setting of BOOT-LOAT area size
Considerations for improving hardware reliability:
. Try to use on-chip crystal, low-frequency system clock, and small output amplitude of oscillation circuit.
. Choose appropriate startup delay parameters
. Use BOD and on-chip watchdog
. Use sleep mode reasonably
. Do not use I/O port to set output low level
. Use internal EEPROM and register MCUCSR to judge reset flag and perform different processing
Improve software design ability and level:
Try to reasonably use high-level language to design and write system programs. Many people think that using assembly language to write programs is more concise, and using high-level language development will waste a lot of program space. In fact, this is a misunderstanding. For an experienced assembly master who is very familiar with a certain microcontroller, he can write more concise code than high-level language. For developers who are not very familiar with assembly language, or who suddenly change to a new microcontroller, can you guarantee that you can write a more concise code than high-level language?
The advantages of high-level language cannot be compared with assembly language:
. Convenient program transplantation
. Robustness of program
. Support for mathematical operations
. Clear structured programming and maintainability of program.
. Collaborative software development with short development cycle.
Today's high-level language compilers (such as C compilers) can generate machine code with high code efficiency. Therefore, it is recommended that you use high-level language to write programs that can be implemented in high-level language as much as possible. In situations where speed and timing requirements are particularly strict, mixed programming methods can be used to solve the problem.
A more in-depth and comprehensive grasp of the regulations of various serial communication protocols:
Embedded systems currently use a large number of serial interface peripheral chips and various communication interfaces, such as RS232, two-wire (I2C), three-wire (SPI), single bus, USB, CAN, TCP/IP, etc. Developers and programmers should understand low-level protocols, be familiar with how hardware implements low-level protocols, how to define reliable upper-level application protocols, and the interface design between low-level protocol drivers and upper-level application protocols (implementation of middle-level software).
Hardware engineers should improve their software writing ability, adopt standard programming methods, perfect software overall framework design, good data structure and program structure system. (Programmers majoring in computer software are not familiar with hardware, most of them write software under the support of operating systems, and do not understand the driver layer and interface of low-level interfaces and protocols, and often cannot write good single-chip system programs.)
The writing of communication interfaces should try
to use interrupts + buffers,
layered + structured design,
and try not to use round-robin methods (reducing the efficiency of AVR). See the URAT (RS232) driver + middle-layer software example.
Use good system design mode:
Try not to use the traditional foreground and background (interrupt) system design mode, as tasks affect and interfere with each other and cannot be operated on a scheduled basis. For example, design an 8-bit LED digital tube display driven by dynamic scanning + a 4*4 matrix keyboard with dynamic scanning.
Use TimeTip + state machine design + CASE structure to implement multi-task parallel operation system design method. Or time-triggered system design. (See: "Time-triggered Embedded System Design Mode" China Electric Power Press 2004.6)
Port small embedded operating systems, such as UCOS-II. There are some free simple operating systems based on AVR on the Internet.
Improve C language programming skills and software application level:
Be familiar with and make good use of higher-level applications such as data structures, pointer applications, and memory management in C.
Be familiar with and understand the characteristics of the high-level language development platform you are using. These platforms are for a certain type of processor and contain many special incompatible statements and extended structures, statements, functions, etc. Although they are easy to use, they should be used reasonably due to their opacity and time uncertainty. For example, getchar() and putchar() in C. AVR has multiple development platforms, each with its own characteristics and shortcomings. The ability to use these platforms in combination and complement each other can improve development efficiency. For example, through the ICC and CVAVR program generator CodeWizard, you can learn and understand the hardware settings of AVR, simplify calculations, and quickly generate basic program modules, such as "a URAT (RS232) low-level driver + middle-level software example".
Previous article:Introduction to PIC 16C84 Microcontroller (Part 2)
Next article:DAC Power Consumption Data Calculation Power Consumption Figures Summary
Recommended ReadingLatest update time:2024-11-16 16:42
- 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)
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TMS320C66x dual loop and multiple loop optimization summary
- Design of multi-channel signal generator based on FPGA+PWM
- 【micropython】STM32 will support arbitrary FS
- Global variables in embedded system programming
- PWM generated voltage calculation table
- Help, I need to exchange an E coin, I still need one
- The official WeChat group of the community has been established: you can chat about Microchip live broadcast and PIC microcontrollers
- C6000 Code Generation Tools - Compiler
- [RVB2601 Creative Application Development] 1: Environment Construction and Hello World
- Analog Electronics Technology (US) Boylstad