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.

[参考译文] TMS320F28377D:使用 XDS560V2仿真器进行调试时、调用 FlashAPI 时、程序将失控

Guru**** 2553260 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1201794/tms320f28377d-when-using-the-xds560v2-emulator-to-debug-calling-the-flashapi-the-program-will-runaway

器件型号:TMS320F28377D

大家好、

以下是客户可能需要您的帮助的问题:

CCS 版本为9.3。

使用 xds560V2仿真器调试28377d 程序、当调用 FlashAPI 来擦除 N 个扇区时、程序无法正常工作(不规则写入、而之前的闪存写入可以成功)。

使用了 xds100v3仿真器、但不存在此问题。 当用这两个仿真器下载的程序离线运行时、运行闪存的操作也很好。

闪存写入命令通过串行接口被发送到 DSP。 屏蔽闪存写入的函数不会出现上述问题。  出现问题时、CCS 有时会显示在地址0x0或0x3ff16a 处。 有时它也会在_Fapi_issueFsmCommand 处突然停止。 该程序只有在飞行后才能再次下载、并且无法重新启动。

您能帮助了解这种情况吗? 谢谢。

此致、

樱桃

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Cherry:

    只是为了确保我正确理解问题、用户是否无法使用 xds560v2擦除闪存的 N 扇区?  它们能够使用 xds100v3成功擦除扇区? 此外、当未连接 JTAG 调试探针时、程序也能正常运行?

    此致、

    Ben Collier

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Ben、您好!

    感谢您的支持、请让我在此详细说明情况:

    使用 XDS560擦除是一个调用 flashapi 以读取和写入内部闪存的程序、但调试所使用的仿真器为 XDS560。 当从外部发出 SCI 命令时、在较低的计算机程序调用 flashapi 进行读取和写入操作期间、特定调用中很可能会报告错误。

    但是、当对 xds100v3执行相同操作时、不会报告错误。 下部计算机程序在 BCDEF 中运行、而不是在 N 扇区中运行。  

    通过 XDS560调试、通过串行接口向 DSP 发送命令、DSP 调用 flashapi 进行数据擦除和写入。 连接仿真器的目的是查看数据是否被正确写入、但是在这个过程中、CCS 错误和 DSP 的直接复位将随机且偶尔发生。  但在此之前、可以正确写入数据。

    通过相同的过程、使用仿真器 xds100v3进行调试就不会出现同样的问题。

    请注意、无论使用哪个仿真器、程序都能在离线状态下正常运行。  

    如有任何疑问、敬请告知。  

    谢谢。此致、

    樱桃

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Cherry:

    他们的程序中有这样的机制:F28377D 在通过 SCI 接收到特定命令时执行闪存擦除?  

    您能给我展示一下客户是如何使用闪存 API 的吗? 您能在此处共享代码吗?或者您能用私人消息发送程序中的那个部分吗?  

    此致、

    Ben Collier

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ben:

    您能向我展示客户是如何使用闪存 API 的吗? 您能在此处共享代码吗?或者您能用私人消息发送程序中的那个部分吗?  [/报价]

    请查看代码:

    void Flash_Write(Uint32 address,Uint16* Buffer,Uint16 length,uint16_t Status)
    {
    Uint32* Buffer32 = (Uint32*)Buffer;
    Uint32 u32Index = 0;
    Uint16 i = 0;
    
    // Disable ECC. ECC does not have to be disabled to do FSM operations like
    // program and erase.
    // However, on Sonata Rev. 0 silicon, due to an OTP ECC errata,
    // disable ECC to avoid ECC errors while using Flash API functions that
    // read TI-OTP
    EALLOW;
    Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
    EDIS;
    
    EALLOW;
    
    // Before performing FSM operations, set the waitstates for FSM operations
    // calculated using RWAIT = (SYSCLK/50MHz)-1
    // If RWAIT results in a fractional value, round it up to the nearest
    // integer.
    // Please note that RWAIT for read operation should be calculated
    // differently. See Internal Memory guide section in TRM for more details.
    
    #if CPU_FRQ_200MHZ
    Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x3;
    #endif
    
    // This function is required to initialize the Flash API based on System
    // frequency before any other Flash API operation can be performed
    #if CPU_FRQ_200MHZ
    oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 200);
    #endif
    
    
    if(oReturnCheck |= Fapi_Status_Success)
    {
    // Check Flash API documentation for possible errors
    Example_Error(oReturnCheck);
    }
    
    // Fapi_getLibraryInfo function can be used to get the information specific
    // to the compiled version of the API library
    //oLibInfo = Fapi_getLibraryInfo();
    
    
    // Fapi_setActiveFlashBank function sets the Flash bank and FMC for further
    // Flash operations to be performed on the bank
    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    if(oReturnCheck |= Fapi_Status_Success)
    {
    // Check Falsh API documentation for possible errors
    Example_Error(oReturnCheck);
    }
    
    // Fapi_getBankSectors function returns the bank starting address, number of
    // sectors, sector sizes, and bank technology type
    // Above information is returned in a structure oFlashBankSectors of type
    // Fapi_FlashBankSectorsType
    /* oReturnCheck = Fapi_getBankSectors(Fapi_FlashBank0,&oFlashBankSectors);
    if(oReturnCheck |= Fapi_Status_Success)
    {
    //Check Falsh API documentation for possible errors
    Example_Error(oReturnCheck);
    }
    */
    if(Status==0)
    {
    // Erase Sector N
    // Sectors A and D have the example code so leave them programmed
    oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
    (uint32 *)address);
    
    // Wait until FSM is done with erase sector operation
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
    // Verify that SectorL is erased. The Erase step itself does a
    // verify as it goes. This verify is a 2nd verification that can be done.
    oReturnCheck = Fapi_doBlankCheck((uint32 *)address,
    Bzero_16KSector_u32length,
    &oFlashStatusWord);
    
    if(oReturnCheck |= Fapi_Status_Success)
    {
    // Check Falsh API documentation for possible errors
    // If Erase command fails, use Fapi_getFsmStatus() function to get the
    // FMSTAT register contents to see if any of the EV bit, ESUSP bit,
    // CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for
    // more details)
    Example_Error(oReturnCheck);
    }
    }
    // A data buffer of max 8 words can be supplied to the program function.
    // Each word is programmed until the whole buffer is programmed or a
    // problem is found. However to program a buffer that has more than 8
    // words, program function can be called in a loop to program 8 words for
    // each loop iteration until the whole buffer is programmed
    
    
    // Example: Program 0xFF bytes in Flash Sector C along with auto-
    // generated ECC
    
    // In this case just fill a buffer with data to program into the flash.
    /* for(i=0;i<=WORDS_IN_FLASH_BUFFER;i++)
    {
    Buffer[i] = i+20;
    }
    */
    
    for(i=0, u32Index = address ;
    (u32Index < (address + length))
    && (oReturnCheck == Fapi_Status_Success); i+= 4, u32Index+= 4)
    {
    oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i,
    4,
    0,
    0,
    Fapi_AutoEccGeneration);
    
    while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
    if(oReturnCheck |= Fapi_Status_Success)
    {
    // Check Flash API documentation for possible errors
    Example_Error(oReturnCheck);
    }
    
    // Read FMSTAT register contents to know the status of FSM after
    // program command for any debug
    oFlashStatus = Fapi_getFsmStatus();
    
    // Verify the values programmed. The Program step itself does a verify
    // as it goes. This verify is a 2nd verification that can be done.
    oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
    2,
    Buffer32+i/2,
    &oFlashStatusWord);
    if(oReturnCheck |= Fapi_Status_Success)
    {
    // Check Flash API documentation for possible errors
    Example_Error(oReturnCheck);
    }
    }
    
    // Fapi_doMarginRead((Uint32 *)Bzero_SectorM_start,Buffer_read32,2,Fapi_NormalRead);
    
    // Enable ECC
    Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;
    
    EDIS;
    
    //Fapi_doMarginRead((Uint32 *)Bzero_SectorM_start,Buffer_read32,5,Fapi_NormalRead);
    // Leave control over flash pump
    // ReleaseFlashPump();
    
    // Example is done here
    Example_Done();
    
    }

    uint16_t Data_r[150];
    float_to_Byte(Location_PID_Data1[0].KP, &Data_r[0]);
    float_to_Byte(Location_PID_Data1[0].KI, &Data_r[4*1]);
    float_to_Byte(Location_PID_Data1[0].KD, &Data_r[4*2]);
    float_to_Byte(Location_PID_Data1[0].MAX_Integration, &Data_r[4*3]);
    float_to_Byte(Location_PID_Data1[0].MIN_Integration, &Data_r[4*4]);
    float_to_Byte(Location_PID_Data1[0].Offect_Num, &Data_r[4*5]);
    
    Flash_Write(Bzero_SectorM_start, Data_r, 136, 0);

    谢谢。此致、

    樱桃

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Cherry:  

    xds100v3和 XDS560V2使用单独的 软件来生成它们发送到器件的位。   这个问题可能是由 XDS560V2软件中的某些问题引起的、这是一个非常具体且难以找到的错误。 这对您的客户来说是一个关键问题吗?或者他们对使用 xds100v3是否满意、因为它不存在此问题?  

    此致、

    Ben Collier

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ben:

    对于您的客户来说,这是一个严重的问题,还是他们对使用 xds100v3感到满意,因为它不存在此问题?  [/报价]

    尽管可以使用 xds100v3进行调试、但下载速度比预期的慢、 xda560现在可用于更快的调试。 找到原因是很好的。

    谢谢。此致、

    樱桃

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Cherry:

    我同意最好找到原因、但 C2000器件可能不是问题、而是 XDS560调试探针。 我已询问 XDS560软件的一位所有者、他们是否知道什么原因可能导致此问题、但他们表示以前没有听说过此问题、 他们没有时间研究特定的代码、除非这是一个关键问题。

    您的客户可以随时尝试其他 JTAG 调试探针吗? XDS110比 XDS100的调试速度更快、可选择将 TCK 频率设置为高达14MHz。 XDS200调试探针可以设置为以20MHz 频率运行。

    此致、

    Ben Collier