Since graduating from my master's degree, I have been working in the automotive embedded industry for three years. Compared with school projects, company projects have stricter requirements on code writing standards and test cases. In the automotive industry, most of the code for engineers is generated by EB Tresos, Davinci and Matlab, and only a few complex driver codes need to be designed by engineers themselves. However, this does not mean that engineers only need to follow the design requirements, tick the graphical configuration tool, generate code, and test it a little. If you only have the ability to configure, generate and test, you can only stay at the junior engineer stage, and it is difficult to undertake the development of a module alone, and it is difficult to have a big breakthrough in salary.
I think the first thing an intermediate engineer needs is debugging ability. In the automotive industry, a project has hundreds of thousands or even millions of lines of code. It is impossible for an engineer to fully understand every module, so debugging ability is necessary. When a problem occurs, the debugging tool can be used to locate the module where the problem occurs, and then the corresponding module manager can be found to modify the module configuration to meet the needs of the actual project.
Next, we take the debugging tool winIDEA as an example to introduce some common debugging techniques to help engineers better solve practical project problems in their projects.
# Tip 1
In C language, codes are divided into global variables and local variables. Global variables are stored in the RAM of the microcontroller, and local variables are stored in the stack. The debugger can view and modify global variables at any time. We can view the configuration of the module and the assignment of variables through the values of all variables. These contents are known to engineers who are new to microcontrollers. However, in actual projects, this function is the most basic and the most critical.
To give a few examples, when debugging, we need to view the values of some local variables. In some cases, we can view them in the Locals interface, but this interface cannot view the values of all local variables. In order to view the values of local variables, we can create a new value of the same type as the local variable, and continuously assign local variables to all variables in the code. Then we can indirectly view the values of key local variables by viewing global variables.
In actual projects, we may need to adjust some parameters. We can constantly modify the code, compile, and then burn the produced elf file to the microcontroller. If this method is used, it will not only reduce work efficiency, but also may damage the microcontroller by constantly burning the code. The most important thing is trouble, which makes work very unhappy. At this time, you can double-click the variable value to modify the value of the global variable. Take the following figure as an example. We need to constantly modify the output duty cycle of different PWMs at work to find the duty cycle most needed in the project. You can first modify the value of DutyCycle, and then set Test_Flag to 1 or 2 to let the function that sets the duty cycle execute once. Using this method, the execution efficiency of the work can be greatly improved.
# Tip 2
In the development of the project, it is often the case that the function enters Det. It may be that our configuration is wrong or the assignment is wrong. Because of various mistakes, the function inevitably enters Det and enters an infinite loop. At this time, the CallStack function is very useful. We can pause the function and then open the CallStack interface to see which function enters Det and causes the function to enter an infinite loop. We can solve the problem step by step. The corresponding window on the right of the double-section function can enter the corresponding function, which is very convenient for debugging.
# Tip 3
When viewing variables, we usually use the watch window. However, when viewing large amounts of data, such as SPI cache data, using the watch window will seriously interfere with the operation of the program, which is manifested as slow data refresh. However, using Memory is very good and the refresh is very smooth, so when viewing large data, using the memory window is very advantageous. In the project, due to various reasons, such as the configuration of the debugging tool, the downloaded program is consistent but the function of the microcontroller is inconsistent. At this time, you can copy all the data in the Flash through the memory window, and then use the tool to compare to see whether the code burned into the microcontroller is consistent.
Due to time constraints, I will only share the above three development and debugging techniques. If you encounter new debugging techniques and common errors in your future work, you can summarize them and share them with readers to facilitate your development work.
Previous article:The advancing Robotaxi, is the road to commercialization still far away?
Next article:Microchip Launches New VelocityDRIVE™ Software Platform and Automotive-Grade Multi-Gigabit Ethernet Switch to Support Software-Defined Cars
- Popular Resources
- Popular amplifiers
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- How much do you know about intelligent driving domain control: low-end and mid-end models are accelerating their introduction, with integrated driving and parking solutions accounting for the majority
- Foresight Launches Six Advanced Stereo Sensor Suite to Revolutionize Industrial and Automotive 3D Perception
- OPTIMA launches new ORANGETOP QH6 lithium battery to adapt to extreme temperature conditions
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions
- TDK launches second generation 6-axis IMU for automotive safety applications
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Classification and circuit composition of power amplifiers
- Can you guys help me analyze this ultrasonic receiving circuit? Is the op amp a bandpass filter? How do I calculate the center frequency?
- Understanding automotive RF front-end design techniques in one article
- Review Weekly Report 20220104: New arrivals~ Linux RISC-V development kit, National Technology M4 hot-selling model, fresh ST60
- Here it comes, here comes the weekly review information~~
- MS5192T replaces AD7792
- Why does the output voltage of a power amplifier have errors? (Part 2)
- [Unmanned driving smart car based on ESP32 road sign identification] Unboxing ESP32-S2-KALUGA-1+K210Sipeed M1 docking station kit
- Challenge and collect cards | Light electric vehicles and power tools are just the right time, Infineon invites you to join the fun!
- script_recording_test_no_reply