请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320F28335 大家好!
我使用 TMS320F28335进行电机控制。 有人会告诉我当整个程序被写入闪存时、程序执行的最大频率吗? 每次微控制器达到运行统计时、是否有办法将已写入程序从闪存移动到 RAM? 如何实现? 以这种方式更快地执行代码?
此致
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
大家好!
我使用 TMS320F28335进行电机控制。 有人会告诉我当整个程序被写入闪存时、程序执行的最大频率吗? 每次微控制器达到运行统计时、是否有办法将已写入程序从闪存移动到 RAM? 如何实现? 以这种方式更快地执行代码?
此致
您好、Jake、
从闪存运行程序会更慢(根据表7.9.7.4 "闪存/OTP 存取时序"、存取时间约为37ns、我不知道这对于程序执行与数据访问是否发生了变化)。 程序从中运行的存储器可以在 CCS 工程的.cmd 文件中进行配置。 最佳方法是将所有代码加载到闪存中、并将需要及时执行的代码移动到 RAM 一次(最好不要重复复制、除非器件断电或复位)。 代码在 RAM 上的执行速度更快、在闪存上执行大部分的初始配置将节省 RAM 上的一些空间。
我提供了一个基本模板、用于配置.cmd 文件以便从闪存启动并使用 F2838x 器件将程序加载到 RAM (您需要调整命名/为您的器件提供的 RAM 单元、但主要观点是使用.TI.ramfunc、.binit、#pragma 语句、 和 memcpy 函数)。
命令链接器文件:
MEMORY
{
/* BEGIN is used for the "boot to SARAM" bootloader mode */
BEGIN : origin = 0x000000, length = 0x000002
BOOT_RSVD : origin = 0x000002, length = 0x0001AF /* Part of M0, BOOT rom will use this for stack */
RAMM0 : origin = 0x0001B1, length = 0x00024F
RAMM1 : origin = 0x000400, length = 0x0003F8 /* on-chip RAM block M1 */
// RAMM1_RSVD : origin = 0x0007F8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
RAMD0 : origin = 0x00C000, length = 0x000800
RAMD1 : origin = 0x00C800, length = 0x000800
RAMLS0 : origin = 0x008000, length = 0x000800
RAMLS1 : origin = 0x008800, length = 0x000800
RAMLS2 : origin = 0x009000, length = 0x000800
RAMLS3 : origin = 0x009800, length = 0x000800
RAMLS4 : origin = 0x00A000, length = 0x000800
RAMLS5 : origin = 0x00A800, length = 0x000800
RAMLS6 : origin = 0x00B000, length = 0x000800
RAMLS7 : origin = 0x00B800, length = 0x000800
RAMGS0 : origin = 0x00D000, length = 0x001000
RAMGS1 : origin = 0x00E000, length = 0x001000
RAMGS2 : origin = 0x00F000, length = 0x001000
RAMGS3 : origin = 0x010000, length = 0x001000
RAMGS4 : origin = 0x011000, length = 0x001000
RAMGS5 : origin = 0x012000, length = 0x001000
RAMGS6 : origin = 0x013000, length = 0x001000
RAMGS7 : origin = 0x014000, length = 0x001000
RAMGS8 : origin = 0x015000, length = 0x001000
RAMGS9 : origin = 0x016000, length = 0x001000
RAMGS10 : origin = 0x017000, length = 0x001000
RAMGS11 : origin = 0x018000, length = 0x001000
RAMGS12 : origin = 0x019000, length = 0x001000
RAMGS13 : origin = 0x01A000, length = 0x001000
RAMGS14 : origin = 0x01B000, length = 0x001000
RAMGS15 : origin = 0x01C000, length = 0x000FF8
// RAMGS15_RSVD : origin = 0x01CFF8, length = 0x000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
/* Flash sectors */
FLASH0 : origin = 0x080000, length = 0x002000 /* on-chip Flash */
FLASH1 : origin = 0x082000, length = 0x002000 /* on-chip Flash */
FLASH2 : origin = 0x084000, length = 0x002000 /* on-chip Flash */
FLASH3 : origin = 0x086000, length = 0x002000 /* on-chip Flash */
FLASH4 : origin = 0x088000, length = 0x008000 /* on-chip Flash */
FLASH5 : origin = 0x090000, length = 0x008000 /* on-chip Flash */
FLASH6 : origin = 0x098000, length = 0x008000 /* on-chip Flash */
FLASH7 : origin = 0x0A0000, length = 0x008000 /* on-chip Flash */
FLASH8 : origin = 0x0A8000, length = 0x008000 /* on-chip Flash */
FLASH9 : origin = 0x0B0000, length = 0x008000 /* on-chip Flash */
FLASH10 : origin = 0x0B8000, length = 0x002000 /* on-chip Flash */
FLASH11 : origin = 0x0BA000, length = 0x002000 /* on-chip Flash */
FLASH12 : origin = 0x0BC000, length = 0x002000 /* on-chip Flash */
FLASH13 : origin = 0x0BE000, length = 0x002000 /* on-chip Flash */
CPU1TOCPU2RAM : origin = 0x03A000, length = 0x000800
CPU2TOCPU1RAM : origin = 0x03B000, length = 0x000800
CPUTOCMRAM : origin = 0x039000, length = 0x000800
CMTOCPURAM : origin = 0x038000, length = 0x000800
CANA_MSG_RAM : origin = 0x049000, length = 0x000800
CANB_MSG_RAM : origin = 0x04B000, length = 0x000800
RESET : origin = 0x3FFFC0, length = 0x000002
}
SECTIONS
{
codestart : > BEGIN
.binit : > FLASH3 /* .binit will execute before main because it's in the linker file */
.text : >> FLASH1 | FLASH2 | FLASH3 | FLASH4
.cinit : > FLASH1
.switch : > FLASH1
.reset : > RESET, TYPE = DSECT /* not used, */
//
// Copies contents from Flash 3 to RAMLS0 and RAMLS1 (if not enough room
// on RAMLS0)
//
.TI.ramfunc : {} LOAD = FLASH3,
RUN = RAMLS0 | RAMLS1,
table(BINIT),
PAGE = 0, ALIGN(4)
.stack : > RAMM1
#if defined(__TI_EABI__)
.bss : > RAMLS5
.bss:output : > RAMGS0
.init_array : > RAMGS1
.const : >> FLASH5 | FLASH6 | FLASH7
.data : > RAMLS5
.sysmem : > RAMLS5
#else
.pinit : > FLASH1
.ebss : >> RAMLS5 | RAMGS0 | RAMGS1
.econst : >> FLASH5 | FLASH6 | FLASH7
.esysmem : > RAMLS5
#endif
ramgs0 : > RAMGS0, type=NOINIT
ramgs1 : > RAMGS1, type=NOINIT
MSGRAM_CPU1_TO_CPU2 > CPU1TOCPU2RAM, type=NOINIT
MSGRAM_CPU2_TO_CPU1 > CPU2TOCPU1RAM, type=NOINIT
MSGRAM_CPU_TO_CM > CPUTOCMRAM, type=NOINIT
MSGRAM_CM_TO_CPU > CMTOCPURAM, type=NOINIT
}
/*
//===========================================================================
// End of file.
//===========================================================================
*/
主程序代码:
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"
//
// This pre-processor command loads the function into the .TI.ramfunc
// section of memory
//
#pragma CODE_SECTION(ramCounter, ".TI.ramfunc");
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// PinMux and Peripheral Initialization
//
Board_init();
//
// C2000Ware Library initialization
//
C2000Ware_libraries_init();
//
// Copy functions from .TI.ramfunc from Flash to RAM; the method of using
// binit replaces memcpy in this example, the line remains as a template
// of how the function can be called
//
//EALLOW;
//memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//EALLOW;
//
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
//
EINT;
ERTM;
while(1);
}
//
// End of File
//
此致、
Omer Amir