In-system programming design of Flash memory in single-chip microcomputer system

Publisher:码字探险Latest update time:2011-10-10 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Reference address:In-system programming design of Flash memory in single-chip microcomputer system

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

Read and write control design of non-volatile flash memory technology NAND Flash memory device
    NOR Flash and NAND Flash are the two main non-volatile flash memory technologies on the market today. Flash is widely used in handheld devices such as digital cameras, mobile phones, personal digital assistants (PDAs), PDAs, and MP3 players because of its non-volatility and erasability. Compared with NOR Flash, NA
[Microcontroller]
Read and write control design of non-volatile flash memory technology NAND Flash memory device
STM32 on-chip Flash memory map, page size, register map
1. How to check Flash size   1.1 By model     The model will be printed on the surface of the MCU and can be obtained by observation. Mine is STM32F103RBT6 (the following analysis is based on this model). Comparing with the STM32 product naming in the figure below, it can be seen that the Flash of STM32F103RBT6 is 128
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号