At present, the ISP mode of 51 core microcontrollers is generally divided into two categories: one is the ISP mode using the JTAG protocol; the other is the ISP mode using a special instruction to make the microcontroller enter the ISP. After entering the ISP mode, you need to control the erase and write logic of the microcontroller yourself. This type of mode can be further divided into two different modes: ① After entering the ISP mode, the microcontroller only provides an interface and no longer runs the program of the slave device. The erase and write logic is all provided by the master device. MTV412 and MTV312 in this system belong to this mode; ② After entering the ISP mode, the slave device will run the program that has been written in a certain area. The programming logic of the chip is controlled by this program in the chip. The master device only serves as a data source for the microcontroller and transmits the data to be erased to the microcontroller, such as Winbond's W79E632.
1 Background
1.1 MTV412 and MTV312
MTV412 and MTV312 are products of Taiwan's Myson Company, mainly video control ICs for LCD Monitors and LCD TVs. This chip can meet the control requirements in video applications and is therefore widely used in video products. In this system, the master device uses the 128 KB MTV412 microcontroller. The slave device uses MTV312, which is a 64 KB 51 series 8-bit microcontroller with ISP function.
1.2 Compilation Environment Keil C51
Keil C51 is a 51 series compatible microcontroller C language software development system produced by Keil Software in the United States. It is a highly efficient C language compiler designed specifically for 805l microcontrollers, in accordance with ANSI standards, and the program code produced has a very high running speed and requires very little storage space, which is completely comparable to assembly language. Cx51 has been fully integrated into a powerful new integrated development environment uVision2. uVision2 provides powerful project management functions, which can easily carry out structured multi-module program design. The source code of the master device of this system is compiled by Keil C51 to obtain the HEX or BIN file required for burning.
1.3 Principle of switching Banks
The traditional 51 series microcontroller is 8-bit, so it can access a maximum of 64 KB address space. If you want to use the 51 series microcontroller to access 128KB space, you must use the method of switching banks. A bank is 64 KB, and the corresponding bank is selected by external hardware. In this system, MTV412 uses the method of switching banks to upgrade the ISP slave device program online. MTV412 switches banks through P3.5. By setting different levels of P3.5, switch to different bank areas. If you want to switch 4 banks, you must control it by 2 ports. Figure 1 shows the 128 KB storage space allocation of MTV412. Among them: the Common area is used to store power-on reset programs, interrupt vectors, global variables, interrupt functions, bank switching programs and library functions; the Bank area is used to store some different application functions.
As shown in Figure 2, this system divides the 128 KB Falsh of MTV412 into Bank0 and Bank1, each 40 KB in size. In the Keil C51 editor, the L51_BANK.A51 assembly file must be added, which contains the number of banks in the system and the functions and ports called for switching banks.
2 System Architecture
The system architecture is shown in Figure 3. First, the file of the slave device MTV312 is generated into a 64 KB HEX or BIN file through Keil C51; then, the file of the master device MTV412 is generated into a 128 KB HEX or BIN file through Keil C5l; finally, the BIN or HEX of the slave device MTV312 is divided into two 32 KB files, which are placed at the 8000H and 18000H positions of the 128 KB of the master device MTV412. The address space allocation of the file is shown in Figure 4.
Burn the program directly to MTV412 through PC or burner. In this way, MTV412 can be separated from PC and directly perform ISP on the slave device on the production line through I2C.
2.1 Hardware Implementation
The hardware circuit of the master device MTV412 is shown in Figure 5. P6 port is used as SCL and P1 is used as SDA. Because P6 is a unidirectional port and P1 is a bidirectional port, SDA not only outputs data but also receives ACK. P1 corresponds to SDA of 8 slave devices, and P6 corresponds to SCL of 8 slave devices. The multi-function ports P3.0 and P3.1 of MTV412 can be used as ordinary I/O ports, SCL and SDA of I2C, or serial port RXD and TXD. This system is set as I2C port, and the program on MTV412 can be directly updated through PC.
2.2 Software Implementation
The master device MTV412 has 128KB of Flash space. Among them, Bank0 (32 KB) and Bank1 (32 KB) store the corresponding program data of the slave device MTV312 and call functions func0 and funcl. The Common area is used to place the program that communicates with the slave device to simulate the ISP process. In the main function, by calling func0 and func1, the corresponding Bank0 and Bank1 contents starting from 8000H are put into the cache area, 256 bytes are read each time, and then ISP is performed in the Common area.
During ISP, the 64 KB program data of the slave device is divided into 256 blocks, each block is 256 bytes.
The ISP process is shown in Figure 6.
① Enter ISP: send I2C start → send 0x4C → send 0x77 → send I2C stop.
② Clear Flash (hardware clear Flash): send I2C start → send 0x7C → send 0x68 and 0x00 → send 0x7C → send 0x00, 0x00 → delay 1 s → send I2C stop.
③ Clear CRC register: send I2C
start → send 0x7c → send 0xD0 → send I2C stop. ④ Flash programming: send I2C start → send 0x7C → send 0xA0, block start address (0x00
~ 0xff) → send I2C stop → loop 256 times (send I2C start → send address 0x00 → send 256 bytes of data → send I2C stop).
⑤ Check CRC: send I2C start → send 0x7C → receive 4-byte CRC check value → compare with the soft-calculated CRC value. If they are equal, send I2C stop; otherwise, re-Flash programming.
⑥ Reset: send I2C start → send 0x7C → send 0x48 and 0x00 → send I2C stop.
To make the slave device MTV312 have ISP function, you must add a program to the main application of the slave device. This program is used to respond to the level changes of the multi-function port SCL and SDA (RXD, TXD). After executing the following program, MTV312 enters ISP mode:
void Intlsp(void)interrupt 2{//Slave device MTV312 external interrupt 1
Conclusion
The implementation method of this system is relatively simple, and it can run independently without a PC, while providing the factory with a simpler and more convenient online ISP. The master device can batch program the slave devices online, which is worth promoting in first-tier factories.
Previous article:Design Idea of Software UART Based on Single Chip Microcomputer
Next article:Repeated Programming of Internal Memory of 87C196MC Single Chip Microcomputer
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
- How to drive a three-phase two-Hall brushless DC motor?
- I have published some theoretical articles before. Today I will simulate and verify the real theoretical data.
- SensorTile.box Sound Control LED Brightness
- Automobile complete vehicle EMC testing, complete vehicle electromagnetic compatibility testing, automobile parts EMC testing
- Motor control video FOC sensorless
- Interrupt controller of C6678 developed by DSP
- Apply for free evaluation: Anxinke WiFi + Bluetooth audio development board ESP32-Audio-Kit!
- [Dry goods sharing] Lithium battery power supply circuit design (boost, charging management, etc.)
- [Register now, see you in Guangzhou on February 25, 2019! ] World Peace Group WPI / GDSM Visual Retail Summit
- Thank you for being there +2019