Flash memory technology is mature and widely used. It combines the cost advantage of OTP memory and the reprogrammable performance of EEPROM. It is an ideal memory at present. Flash memory is electrically erasable, requires no backup power to protect data, can be programmed online, has high storage density, low power consumption, and low cost. In general, we believe that Flash memory has the basic characteristics of inherent non-volatile, easy to update, and reliable.
From the basic characteristics of the Flash memory, it can be seen that in the single-chip microcomputer, the F1ash memory can be used to solidify the program. In general, the F1ash memory is used in the programmer to work in this situation, called the monitor mode or the writer. Chess, which is similar to the general EPROM, 0TP, EEPROM loader. On the other hand, since the flash memory has an electrically erasable function, it is possible to update the teaching data or program of the F1ash storage area during the running of the program, and the flash memory works in this case, called user mode (User Mode) or online programming mode.
Two programming modes of Flash memory: 1. Monitor mode or Writer mode 2, user mode or online programming mode . Both modes have their own advantages and disadvantages: the monitoring mode requires external hardware support, but does not require the existence of the internal program of the microcontroller. Therefore, it is suitable for programming and writing to the new factory chip, or for overall erasing and writing of the chip; the user mode can be entered when the microcontroller is working normally, so some unit contents of some flash memories are commonly used during the running of the program. Modifications, especially suitable for dynamic program updates and storage of operational data for the target system. In general, the two modes are consistent with the programming operation of the flash memory, the difference is the way and environment in which these programs are called.
   Below we will explain in detail the Flash memory online programming modeThere are two basic operation Flash programming: erase (Erase) and write (Program). The meaning of the erase operation is to change the contents of the memory cell from binary 0 to 1, and the meaning of the write operation is to change the contents of the memory cell from binary 1 to 0. Erase and write operations are accomplished by setting or clearing one or more bits in the Flash Memory Control Register (FLCR).
Flash command execution flow
Firstly, the Flash programming subroutine of GP32 MCU is given. Then, an example of Flash online programming in user mode is given, and it is verified by serial communication with PC. The PC side uses VB language programming.
1 Flash memory erase and write assembly subroutine
Since there is no firmware flash programming subroutine in the monitoring ROM of the GP32 microcontroller, the Flash can be programmed online during the operation. The user program that is initially loaded must include the erase and write subroutine for Flash. Since the program resides in the flash area, when the erase and write subroutine is run, the entire flash area is added with a programming voltage higher than the normal working voltage, which makes the reading of the flash area unstable, which may cause the program to not execute normally. In order to make the erase and write programs execute normally, the erase and write subroutine needs to be moved into the RAM and transferred to the RAM area for execution. To do this, you need to open a buffer in the RAM area for the program to move into use. The following figure shows the file organization of the assembly project of Flash online programming.
2 Erase and Write Subprogram Programming Points Description
Using Flash online programming technology can eliminate external EEPROM, which not only simplifies circuit design, but also improves system stability. However, the technical literature of Flash online programming is relatively small, especially the utility program is still rarely seen at present, and the technical details concerning Flash online programming should be carefully considered. Since the erase and write subroutine is copied to the RAM for execution, the two subroutines we have given already contain the program procedure that is copied and transferred to the RAM. It is because of this special process, based on actual programming and project development. The experience accumulated in the process, the following points of attention are proposed for the reader's reference:
1RAM should have enough buffers to store the subroutine copied to RAM. The specific value is to take the larger of the erase and write subroutines. Their size can be found in the compiled .LST file.
2 The erase and write subroutines to be called in the subroutine are followed by the same time, so that they can be copied to the RAM at the same time. The last label is added for the convenience of copying. Otherwise, other methods are used to obtain the end address when programming. Becomes non-standard.
3 The call to the delay subroutine in the erase and write subroutine must use the "BSR subroutine name" instead of the "JSR subroutine name" because the subroutine here is copied to the RAM for execution. Has changed, so only relative calls can be used.
4 Erase subroutine and write subroutine and the delay subroutine in it. If there is a jump statement, you cannot use "JMP address", only "BRA address" can be used. The reason is the same as above.
5 When using different types of chips, the delay time in the above subroutine should be changed according to the chip manual. The delay subroutine should also be changed according to different bus frequencies to ensure that the time meets the timing requirements.
6 The area that has not been written after an erase can be called again to write to the subroutine write, but the written area cannot be overwritten without being erased.
7 Since the erase is to erase one page at a time (128 bytes), the data should be reasonably arranged to avoid accidental erasure.
8 The definition of the top-level address shall be in accordance with the rules defined by the protection register FLBPR, that is, for the GP32, the lower 7 bits of the page address are 0.
9 The flash memory area used for online programming should be in front of the program flash memory area, because the flash protected area is the address determined by FLBPR to the end.
remote control car motor,rc boat engine,rc helicopter motor,slot car motors,toy motor price,toy dc motor
Shenzhen Maintex Intelligent Control Co., Ltd. , https://www.maintexmotor.com