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.

DSP28034如果没有外部eeprom如何保存掉电保持的参数

Other Parts Discussed in Thread: C2000WARE

如题,有哪些方法,求指教!

  • 你好,如果要保存芯片运行参数的话需要用到flash读写,而flash读写的话必须使用flash API函数,可以参考以下路径内容:
    C:\ti\c2000\C2000Ware_3_03_00_00\libraries\flash_api\f2803x
  • 我的目的是将参数写入FLASHB中
    我仿照例程写了代码后,执行发现执行操作后,芯片好像复位了。
    这是我定义的F28034 FLASH地址
    SECTOR Sector[8]= {
    (Uint16 *) 0x3E8000,(Uint16 *) 0x3E9FFF, //FLASHH
    (Uint16 *) 0x3EA000,(Uint16 *) 0x3EBFFF, //FLASHG
    (Uint16 *) 0x3EC000,(Uint16 *) 0x3EDFFF, //FLASHF
    (Uint16 *) 0x3EE000,(Uint16 *) 0x3EFFFF, //FLASHE
    (Uint16 *) 0x3F0000,(Uint16 *) 0x3F1FFF, //FLASHD
    (Uint16 *) 0x3F2000,(Uint16 *) 0x3F3FFF, //FLASHC
    (Uint16 *) 0x3F4000,(Uint16 *) 0x3F5FFF, //FLASHB
    (Uint16 *) 0x3F6000,(Uint16 *) 0x3F7FFF, //FLASHA
    };

    void SaveFlash( void )
    {

    GpioDataRegs.GPADAT.bit.GPIO24 = 0;
    Status = Example_CsmUnlock();
    if(Status != STATUS_SUCCESS)
    {
    Example_Error(Status);
    }
    EALLOW;
    Flash_CPUScaleFactor = SCALE_FACTOR;
    EDIS;
    EALLOW;
    Flash_CallbackPtr = &MyCallbackFunction;
    EDIS;
    MyCallbackCounter = 0; // Increment this counter in the callback function
    // Jump to SARAM and call the Flash API functions
    Example_CallFlashAPI();
    GpioDataRegs.GPADAT.bit.GPIO24 = 1;
    }


    #pragma CODE_SECTION(Example_CallFlashAPI,"ramfuncs");
    void Example_CallFlashAPI(void)
    {
    Uint16 i;
    Uint16 Status;
    Uint16 *Flash_ptr; // Pointer to a location in flash
    Uint32 Length; // Number of 16-bit values to be programmed
    float32 Version; // Version of the API in floating point
    Uint16 VersionHex; // Version of the API in decimal encoded hex

    VersionHex = Flash_APIVersionHex();
    if(VersionHex != 0x0100)
    {
    // asm(" ESTOP0");
    Flash_Status=VersionHex;
    Flash_Result=1;
    return;
    }


    Version = Flash_APIVersion();
    if(Version != (float32)1.00)
    {
    Flash_Status=Version;
    Flash_Result=2;
    return;

    }

    // Example: Erase Sector B - Sector H
    // Sectors A has example code so leave them unerased

    // SECTORA-SECTORH are defined in Flash2803x_API_Library.h
    Status = Flash_Erase((SECTORB),&FlashStatus);
    if(Status != STATUS_SUCCESS)
    {
    Example_Error(Status);
    Flash_Result=3;
    return;
    }


    /*for(i=0;i<WORDS_IN_FLASH_BUFFER;i++)
    {
    Buffer[i] = 0x100+i;
    }
    */
    //FLASH B
    Flash_ptr = Sector[6].StartAddr;
    Length = 50;
    Status = Flash_Program(Flash_ptr,Buffer,Length,&FlashStatus);
    if(Status != STATUS_SUCCESS)
    {
    Example_Error(Status);
    Flash_Result=4;
    return;
    }

    Status = Flash_Verify(Flash_ptr,Buffer,Length,&FlashStatus);
    if(Status != STATUS_SUCCESS)
    {
    Example_Error(Status);
    Flash_Result=5;
    return;
    }



    Example_Done();
    return;


    }

    下面是我通过CAN通讯设置的标记后进行FLASH操作的代码
    //保存参数
    Uint16 * FlashStartAddr=(Uint16 *)0x3F4000;
    Uint16 * FlashEndAddr=(Uint16 *)0x3F4032;
    if(SaveFlag==1)
    {
    DisableDog();
    DINT;
    for(i=0;i<50;i++)
    {
    Buffer[i]=PARAMS.Buffer[i];
    }
    MyCallbackCounter=0;

    SaveFlash();
    MemCopy(FlashStartAddr, FlashEndAddr, PARAMS.Buffer);
    EINT;

    }
  • 现在还是不能保存,麻烦帮忙看一下