About C2000 program transfer from flash to RAM
[Copy link]
Generally speaking, the program runs much faster in RAM than in FLASH. For example, if the F28335 runs a program in Flash at the highest system clock of 150MHz, it needs 5 waiting cycles, while running the program in RAM requires zero waiting cycles. This is why many users mentioned that the program runs normally in online simulation, but it does not run normally when burned to flash.
In order to improve the execution speed of key codes in applications, the corresponding codes in Flash can be moved to RAM for execution. The specific implementation is generally divided into three steps:
Declare the ramfuncs address space in the cmd file, including the Flash and RAM addresses corresponding to the code when it is loaded (downloaded) and run (executed);
查看详情
Define the code moving function, MemCopy(): its main function is to move the code corresponding to Flash to RAM;
查看详情
In main.c, first declare the function to be moved, declare three external variables, and execute MemCopy() to move the corresponding function to RAM;
查看详情
By adding the above operations to the project, you can call the relevant functions normally, and the function will automatically jump to RAM to run.
Replenish:
In order to effectively improve the code execution rate, it is recommended to move only some key codes to RAM for execution. It is not necessary to move all the codes of the main() function to RAM.
In addition, as far as I know, if the FLASH API and delay_us() function are used in the program, this part of the code must be copied to RAM for execution. The FLASH API has the following provisions:
Flash API execution is interruptible; however, there should not be any read or fetch access from the Flash bank/OTP when an erase or program operation is in progress. Therefore, the Flash API functions, the user application functions that call the Flash API functions, and any ISRs (Interrupt service routines,) must be executed from RAM. For example, the entire code snippet shown below should be executed from RAM and not just the Flash API functions. The reason for this is because the Fapi_issueAsyncCommandWithAddress() function issues the erase command to the FSM, but it does not wait until the erase operation is over. As long as the FSM is busy with the current operation, there should not be a Flash access.
If the delay_us() function is not copied to RAM, it will usually enter an illegal interrupt.
Example reference: C:\ti\ controlSUITE \device_support\f2833x\v142\DSP2833x_examples_ccsv5\flash_f28335
Document reference: 查看详情
|