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.

TMS320F28035: InitFlash()程序跑飞

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE,

28035在程序初始化中,把看门狗关掉了,硬件电路也是好的(烧录别的程序验证过),在执行InitFlash()中就跑飞了,跑的代码段为:3ff599:  7625  ESTOP0 。但是单步执行能把InitFlash(),全速运行就不行了。InitFlash()的程序:

void main(void)
{
//Initialize System Control
//PLL WatchDog enable Peripheral
InitSysCtrl();

//Initialize GPIO
InitGpio();

iRamCheck();

MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
MemCopy(&Cla1funcsRunStart, &Cla1funcsLoadStart, &Cla1funcsLoadSize);

InitFlash();

InitialInterrupts();

...........................................

void InitFlash(void)
{
EALLOW;

FlashRegs.FOPT.bit.ENPIPE = 1;
FlashRegs.FBANKWAIT.bit.PAGEWAIT = 2;
FlashRegs.FBANKWAIT.bit.RANDWAIT =2;
FlashRegs.FOTPWAIT.bit.OTPWAIT = 2;
FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF;
FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF;

EDIS;

asm(" RPT #7 || NOP");
}

  • 你好,是通过设置断点的方式测出来问题出在InitFlash()吗?还是其他方法?

    我看InitFlash()的代码也没什么问题,或者你可以将OTPWAIT设置大一点,但一般只要不是0都可以。

  • hi green,

    1、把断点设置在InitFlash()程序里边中的任何一句话,都会出现以下程序跑飞的提示:

    2、但是把断点设置在主程序InitFlash()这里,用单步运行可以进入到程序里边。但是单步运行可以把InitFlash()跑完。

    3、把断点1设置在主程序InitFlash()这里,断点2设置在FlashRegs.FOTPWAIT.bit.OTPWAIT = 2包括这句和前边的3句,全速运行都可以停止下来,但是我把断点2设置在FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF这句,出现1中的一样的结果。

    4、我把FlashRegs.FOTPWAIT.bit.OTPWAIT = 20,也是出现一样的问题。

  • 会不会是我CMD文件写的不好,导致内存存储出现了问题。用了CLA

  • 我认为这个问题跟cmd文件关系不大,或者你可以试试换一下官方的cmd文件:C:\ti\c2000\C2000Ware_4_01_00_00\device_support\f2803x\common\cmd

    有没有修改过系统初始化里面的系统频率之类的?

  • 系统频率配置用的官网的,CMD用了官网的也不行,把以下3句屏蔽了就执行时钟配置,到了initFlash中一样是跑飞。

    iRamCheck();

    MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
    MemCopy(&Cla1funcsRunStart, &Cla1funcsLoadStart, &Cla1funcsLoadSize);

    此外我的代码原来是28033的,我现在在28035上跑的,已经把属性里边+CCXML中都改成了28035,其他的地方没修改,这个原因有没有可能影响?

  • 我认为跟芯片型号关系应该也不大,因为这两款芯片的区别就在flash大小上,其他的memory都是一样的。

    我建议你用官方例程测试一下能否正常initFlash,这样可以判断是否是硬件有问题。因为我看了软件上cmd文件、initFlash代码和程序代码都没发现什么问题。如果硬件也没问题的话可能要麻烦你上传一下工程再系统地看一下

  • hi Green,

         问题已经解决了,在MemCopy程序中用的是大写的Ramfuncs,但是在程序中是是小写的ramfuncs,所以就出问题了。改了就可以进主程序了。

    但是用到CLA这部分,拷到RAM里边出现了死循环,一直停在了MemCopy子程序中,我把几个代码贴上来,帮忙看看,谢谢!

    1、下边的CLA的拷到ram中,是第1句程序还是第2句?我现在用第一句的时候一直停留在memcopy这个函数中。

    2、MemCopy函数是:

    3、CLA定义的程序是:

    /*==================================================================================*/

    4、CMD文件
    /* User specific Linker command file for running from FLASH */
    /*==================================================================================*/
    /* FILE: F28035_FLASH_HVPM_Sensored.CMD */
    /* */
    /* Description: Linker command file for User custom sections targetted to run */
    /* from FLASH. */
    /* */
    /* Target: TMS320F28035 */
    /* */
    /* Version: 1.00 */
    /* */
    /*----------------------------------------------------------------------------------*/
    /* Copyright Texas Instruments 锟� 2009 */
    /*----------------------------------------------------------------------------------*/
    /* Revision History: */
    /*----------------------------------------------------------------------------------*/
    /* Date | Description */
    /*----------------------------------------------------------------------------------*/
    /* 4/13/09 | Release 1.0 New release. */
    /*----------------------------------------------------------------------------------*/

    /* Define the memory block start/length for the F28035
    PAGE 0 will be used to organize program sections
    PAGE 1 will be used to organize data sections

    Notes:
    Memory blocks on F2803x are uniform (ie same
    physical memory) in both PAGE 0 and PAGE 1.
    That is the same memory region should not be
    defined for both PAGE 0 and PAGE 1.
    Doing so will result in corruption of program
    and/or data.

    L0 memory block is mirrored - that is
    it can be accessed in high memory or low memory.
    For simplicity only one instance is used in this
    linker file.

    Contiguous SARAM memory blocks or flash sectors can be
    be combined if required to create a larger memory block.
    */

    _Cla1Prog_Start = _Cla1funcsRunStart;
    -heap 0x200
    -stack 0x200

    // Define a size for the CLA scratchpad area that will be used
    // by the CLA compiler for local symbols and temps
    // Also force references to the special symbols that mark the
    // scratchpad are.
    // CLA_SCRATCHPAD_SIZE = 0x100;
    --undef_sym=__cla_scratchpad_end
    --undef_sym=__cla_scratchpad_start

    MEMORY
    {
    /* Note that the memory allocation below does not create sections as necessary for
    the CLA on the F2803x.
    */

    PAGE 0:
    progRAM : origin = 0x008000, length = 0x001000 /* on-chip RAM (L0-L2)*/
    RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
    OTP : origin = 0x3D7800, length = 0x000400 /* on-chip OTP */
    FLASHH : origin = 0x3E8000, length = 0x002000 /* on-chip FLASH */
    FLASHGtoD : origin = 0x3EA000, length = 0x008000 /* on-chip FLASH */
    //FLASHG : origin = 0x3EA000, length = 0x002000 /* on-chip FLASH */
    //FLASHF : origin = 0x3EC000, length = 0x002000 /* on-chip FLASH */
    //FLASHE : origin = 0x3EE000, length = 0x002000 /* on-chip FLASH */
    //FLASHD : origin = 0x3F0000, length = 0x002000 /* on-chip FLASH */
    FLASHC : origin = 0x3F2000, length = 0x002000 /* on-chip FLASH */
    FLASHA : origin = 0x3F6000, length = 0x001F80 /* on-chip FLASH */
    CSM_RSVD : origin = 0x3F7F80, length = 0x000076 /* Part of FLASHA. Program with all 0x0000 when CSM is in use. */
    BEGIN : origin = 0x3F7FF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
    CSM_PWL : origin = 0x3F7FF8, length = 0x000008 /* Part of FLASHA. CSM password locations in FLASHA */

    IQTABLES : origin = 0x3FE000, length = 0x000B50 /* IQ Math Tables in Boot ROM */
    IQTABLES2 : origin = 0x3FEB50, length = 0x00008C /* IQ Math Tables in Boot ROM */
    IQTABLES3 : origin = 0x3FEBDC, length = 0x0000AA /* IQ Math Tables in Boot ROM */

    BOOTROM : origin = 0x3FF27C, length = 0x000D44 /* Boot ROM */
    RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
    VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */

    PAGE 1 :
    BOOT_RSVD : origin = 0x000000, length = 0x000050 /* Part of M0, BOOT rom will use this for stack */
    RAMM0 : origin = 0x000050, length = 0x0003B0 /* on-chip RAM block M0 */
    //RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
    dataRAM : origin = 0x009000, length = 0x001000 /* data RAM (L3) */
    FLASHB : origin = 0x3F4000, length = 0x002000 /* on-chip FLASH */

    CLA_CPU_MSGRAM : origin = 0x001480, length = 0x000080 /* CLA-R/W, CPU-R message RAM */
    CPU_CLA_MSGRAM : origin = 0x001500, length = 0x000080 /* CPU-R/W, CLA-R message RAM */
    }


    SECTIONS
    {
    /* Allocate program areas: */
    .cinit : > FLASHA, PAGE = 0
    .pinit : > FLASHA, PAGE = 0
    .text : > FLASHGtoD, PAGE = 0

    codestart : > BEGIN PAGE = 0
    Ramfuncs : LOAD = FLASHH,
    RUN = progRAM,
    LOAD_START(_RamfuncsLoadStart),
    LOAD_END(_RamfuncsLoadEnd),
    RUN_START(_RamfuncsRunStart),
    PAGE = 0
    /* debug only */
    Ramfuncs_1 : LOAD = FLASHH,
    RUN = RAMM1,
    LOAD_START(_RamfuncsLoadStart_1),
    LOAD_END(_RamfuncsLoadEnd_1),
    RUN_START(_RamfuncsRunStart_1),
    PAGE = 0

    csmpasswds : > CSM_PWL PAGE = 0
    csm_rsvd : > CSM_RSVD PAGE = 0

    /* Allocate uninitalized data sections: */
    .stack : > RAMM0, PAGE = 1
    .ebss : > dataRAM, PAGE = 1
    .esysmem : > dataRAM, PAGE = 1

    /* Initalized sections go in Flash */
    /* For SDFlash to program these, they must be allocated to page 0 */
    .econst : > FLASHA PAGE = 0
    .switch : > FLASHA PAGE = 0

    .scratchpad : > dataRAM, PAGE = 1
    .bss_cla : > dataRAM, PAGE = 1
    .const_cla : > dataRAM, PAGE = 1

    /* Allocate IQ math areas: */
    IQmath : > FLASHA, PAGE = 0
    IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD

    Cla1Prog : LOAD = FLASHC,
    RUN = progRAM,
    LOAD_START(_Cla1funcsLoadStart),
    LOAD_END(_Cla1funcsLoadEnd),
    RUN_START(_Cla1funcsRunStart),
    LOAD_SIZE(_Cla1funcsLoadSize),
    PAGE = 0

    GROUP : LOAD = FLASHB,
    RUN = dataRAM,
    LOAD_START(_Cla1mathTablesLoadStart),
    LOAD_END(_Cla1mathTablesLoadEnd),
    RUN_START(_Cla1mathTablesRunStart),
    LOAD_SIZE(_Cla1mathTablesLoadSize),
    PAGE = 1

    {
    CLA1mathTables
    .const_cla
    }


    Cla1ToCpuMsgRAM : > CLA_CPU_MSGRAM PAGE = 1
    CpuToCla1MsgRAM : > CPU_CLA_MSGRAM PAGE = 1

    .reset : > RESET, PAGE = 0, TYPE = DSECT
    vectors : > VECTORS PAGE = 0, TYPE = DSECT


    /* Uncomment the section below if calling the IQNexp() or IQexp()
    functions from the IQMath.lib library in order to utilize the
    relevant IQ Math table in Boot ROM (This saves space and Boot ROM
    is 1 wait-state). If this section is not uncommented, IQmathTables2
    will be loaded into other memory (SARAM, Flash, etc.) and will take
    up space, but 0 wait-state is possible.
    */
    /*
    IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
    {

    IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)

    }
    */
    /* Uncomment the section below if calling the IQNasin() or IQasin()
    functions from the IQMath.lib library in order to utilize the
    relevant IQ Math table in Boot ROM (This saves space and Boot ROM
    is 1 wait-state). If this section is not uncommented, IQmathTables2
    will be loaded into other memory (SARAM, Flash, etc.) and will take
    up space, but 0 wait-state is possible.
    */
    /*
    IQmathTables3 : > IQTABLES3, PAGE = 0, TYPE = NOLOAD
    {

    IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)

    }
    */

    }

  • 建议有新问题的话可以重新发布一个帖子来咨询,否则有时候帖子多,追问的帖子很有可能会被遗漏。

    1、memcopy这个函数主要是用于将flash内的程序搬移到ram中执行,以提高执行速度的。不知道你的程序是仿真还是离线跑?如果离线跑的话就不需要这句代码参与。具体可以看一下:https://e2echina.ti.com/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/185635/c2000?tisearch=e2e-sitesearch&keymatch=%25252522%252525E4%252525B8%252525B2%252525E5%2525258F%252525A3%252525E5%2525258D%25252587%252525E7%252525BA%252525A7%25252522#

    2、现在的程序基本都是使用memcpy函数,

    memcpy是编译器内嵌函数,编译器自动会编译这个函数,不需要这个源代码。

    而memcopy函数是ti自己写的,可以在最开始的版本的common文件夹找到这个源文件,后来新的版本就替换掉了,直接用内嵌函数memcpy。

    现在新版的一般使用memcpy函数,两者功能差不多,但是函数本身的定义和.TI.ramfunc的定义有区别。