Recently, the boot function was added to c8051fxxx. Because boot occupies the flash Address Space starting from 0, the application needs to modify the start address. During the test, it was found that programs without RTX-51 could boot normally, but applications containing rtx51 could not load. After analyzing the compiled map file, we found that the rtx51 code occupies the boot space. Open the conf_tny.a51 file and find the following code:
CSEGAT0BH JMP TIMERINT
Therefore, the interrupt vector of the timer is changed to 0x100bh. After re-compilation, the timer still cannot be loaded normally.
Finally, I found the answer on Keil's official website.
Http://www.keil.com/support/docs/1640.htm
MCU interrupt vectors are distributed after the reset (0x0000) and arranged according to the rules. If you change the compiler settings, such as 51, you can change the position of the program in flash and the starting point of the interrupt vector, for example, change 0x1000 to 0x1000, that is, map the 0x0000 address content to 0 x, and use 0x1000 as a virtual reset address. After compilation, the interrupt vector is installed after 0x1000. However, hardware redirection cannot be changed. That is to say, after the interruption occurs, it still enters the vector table with 0 x as the reset address. However, in this vector table, you do not need to jump directly to the interrupt service program. Instead, you need to manually jump to the virtual interrupt vector table, and then jump from the virtual interrupt vector table to the interrupt service program. However, the original vector table may be empty. Therefore, you need to add a program to determine and manually jump to the new vector table.
During compilation, the app program is interrupted to the vector table, and the boot program uses the original vector table. Therefore, the boot service will be interrupted at any time. In the boot interrupt service program, determine whether the current program is executing the boot zone or the app zone. If it is executing the app zone, you can jump to the app to interrupt the service program (the entry vector has been scheduled to be placed after 0x1000 ).
My practice is to put boot in flash0x0000 ~ 0x1000. The program does not use interruptions, but maps the virtual interrupt vector table used by the app. The boot startup. A51 virtual interrupt ing is as follows:
?C_C51STARTUP SEGMENT CODE?STACK SEGMENT IDATA RSEG ?STACK DS 1 EXTRN CODE (?C_START) PUBLIC ?C_STARTUPCSEG AT 0x2bLJMP 0x102bCSEG AT 0x4bLJMP 0x104bCSEG AT 0x23LJMP 0x1023CSEG AT 0x1bLJMP 0x101bCSEG AT 0x0bLJMP 0x100b CSEG AT 0?C_STARTUP: LJMP STARTUP1 RSEG ?C_C51STARTUP
If tiny51 is used in the app, you need to modify conf_tny.a51, and modify the code range 0x1000 ~ of bl51locate ~ 0 xFFFF. Of course, the starting address of startup. A51 must be changed to 0x1000.
Download the Hex file from boot is written to flash based on the hex address after compilation.