With the tightening of emission regulations, the engine electronic control unit (ECU) has become an essential part of modern cars. In the single-chip system of engine control unit, Flash memory has become a basic configuration, mainly used to store control program code.
There are three ways to load program code into Flash memory: the first method is to require suppliers to write data before the memory is shipped, but it cannot meet the requirements of modifying programs during the product development stage; the second method is to use a programmer to program, but because Flash memory is developing towards miniaturization and surface mount, it is difficult to program Flash memory using a programmer; the third method is to install the memory on a circuit board for programming, that is, in-system programming (ISP). This programming method is to program the Flash memory through the system's microprocessor, without the need for other programming equipment and additional programming power supply, and has the advantages of flexibility and convenience. Therefore, when designing the engine control unit, the in-system programming of the memory AM29F010B is realized in combination with the M68HC11 power-on boot program design.
1 In-system programming technology of Flash memory
AM29F010B is a Flash memory produced by AMD. This Flash memory is easy to program. This chip only needs a single 5V power supply to generate high voltage internally for programming and erasing operations. Users only need to write standard microprocessor instructions to its command register, and the specific programming and erasing operations will be implemented by the internal circuit.
When writing a program, you need to pay attention to the fact that only the erase instruction can change "0" to "1", and the erase result is "1"; while the programming instruction cannot write "0" to "1", so when the user is programming the Flash memory, he should erase it first and then program it.
2 M68HC11 and Bootstrap Mode
M68HC11 is a microcontroller unit (MCU) launched by Motorola. Due to its superior performance, it is currently widely used in the field of engine control. M68HC11 has a power-on boot mode, which allows the user program to be downloaded to the internal RAM area through the serial interface (SCI), and then the M68HC11 is transferred to the user program for execution. The downloaded program can run like any ordinary user program. Although the power-on boot mode is a single-chip mode, the mode control word can be changed in this mode, so external resources can also be accessed.
The hardware mode selection is controlled by the MODA and MODB pins when the MCU is reset. The logic states of MODA and MODB are latched before the RESET pin level goes high. When the RESET pin goes high, the mode selection pin no longer has any effect on the MCU's operating mode. If the MODA and MODB pins are all low during reset, the MCU enters the power-on boot mode.
3 Implementation of In-System Programming
3.1 Hardware Solution
In order to program the AM29F010B in-system through M68HC11, in addition to the design of basic components, this system has made the following hardware preparations:
1) In order to be able to download program code from the computer, that is, to communicate with the computer, this system has designed MAX232 to convert TTL level and RS232 level;
2) In order to enable the MCU to enter the power-on boot mode when it is turned on or reset, it is necessary to design jumpers at the MODA and MODB pins to make them low level when reset. The hardware solution diagram is shown in Figure 1.
Figure 1 Hardware solution
3.2 In-system programming software solution
When the microcontroller is reset and enters the power-on boot mode, it will automatically initialize the serial port and then receive the program through the serial port, put it into RAM, and automatically jump to this program for execution. The design relies on this program to implement programming of the external Flash memory.
3.2.1 MCU Program
This program needs to be downloaded to the internal RAM of M68HC11 and starts to execute after the boot program is completed. In this system, it is used to communicate with the computer to receive program code and use the received code to program the external Flash memory AM29F010B.
The execution process of the program is 1) perform initialization operation; 2) wait for the start byte "W"; 3) wait for the programming start address; 4) erase the Flash EPROM and send the data at the erased addresses FFFE and FFFF; 5) receive binary data and perform programming operations; 6) send AA to indicate that the programming is successful and start executing the external program. Since the RAM of M68HC11 is only 256 bytes, the program is written in assembly language. The following are several subroutines.
/3 Initialization, the program is stored in the RAM address, the single chip is switched to extended mode, and the baud rate is set to 96003/
ORG
$0
START LDS #$FF
LDX #$1000
BSET hprio,X
,#00100000B BCLR hprio,X,#00010000B
BCLR hprio,X,#01000000B
LDAA #00110000B
STAA BAUD
/3 Chip erase subroutine 3/
ERASE_FLASH ldab #$AA
stab $555
ldab #$55
stab $2AA
ldab #$80
stab $555
ldab #$AA
stab $555
ldab #$55
stab $2AA
ldab #$10
stab $555
rts
/3 programming subroutine 3/
FlashProgByte ldab #$AA
stab $555
ldab #$55
stab $2AA
ldab #$A0
stab $555
staa X
This is a program written according to the timing requirements of AM29F010B programming. The timing is shown in Table 1 and Table 2.
[page]
3.2.2 Computer Program
The task of the computer program is to communicate with the MCU system, transmit the user program code to be run in the MCU RAM and the code to be loaded into the Flash memory to the MCU system, monitor the execution of the MCU programming process, and provide timely feedback on programming information.
In this system, C language is used for computer programming. Since the data information required by the microcontroller power-on boot program is in binary format, a data array is made according to the results of the above assembly program compilation, and each unit stores 1 byte of data.
Regarding the programming process of monitoring the single-chip microcomputer, this system does not use a complex status bit checking mechanism, but a simple method. When the single-chip microcomputer writes data to an address and then reads the content, if it is different from the original data, the read operation is performed repeatedly here. After the computer program sends data, it monitors the serial port. If there is no data returned at the serial port within a certain period of time, it is considered a timeout and programming fails. The computer program flow is shown in Figure 2.
Figure 2 Computer program flow chart
4 Conclusion
This article combines the power-on boot function of M68HC11 to introduce the method of using in-system programming technology to write program code into Flash memory, and gives the program flow chart of the corresponding links and program examples of some operations. This method is applied in the development of engine control systems, making programming very convenient, speeding up the progress of the project and shortening the development cycle. I believe that this method can also be widely used in other fields.
Previous article:Design of infrared communication interface circuit controlled by single chip microcomputer
Next article:Fire monitoring solution based on ARM
Recommended ReadingLatest update time:2024-11-16 18:03
- Popular Resources
- Popular amplifiers
- In-depth exploration of embedded operating system design, architecture and development from scratch (written by Peng Dong)
- Single Chip Microcomputer and Embedded System (Edited by Guan Yongfeng and Yu Hongqi)
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- STC MCU Principles and Applications: Analysis and Design from Devices, Assembly, C to Operating Systems: A Three-Dimensional Tutorial (He Bin)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- 【Qinheng RISC-V core CH582】Upgrade program via Bluetooth
- MSP430 and Audio
- I want to switch careers to Linux software, and I found a job with only one day off a week. Should I take it?
- Could you please tell me what kind of circuit can output such a voltage?
- 4412 Development Board Qt Timer - Experimental Steps and Partial Code
- LNA Design Based on ADS
- When I wrote the program, I saw TMOD=1, but I didn't see any operation on each bit. What's the meaning of these 8 bits? And some...
- Download Keysight Technologies e-books and get gifts!
- Simulating Microstrip Elliptical Low-Pass Filter Using ADS Software
- STM32L151 low power consumption problem