Other Parts Discussed in Thread:MOTORWARE, C2000WARE, TMS320F28027F
芯片是TMS320F28027F,把C2000ware里的Flash28_Api例程,移植到了motorware的lab05b例程里,flash读取版本校验没问题,但加入擦除函数后,程序就跑死了,仿真运行,提示非法访问(Error – 1142 @ 0x0);
1、我把我的CMD文件放在Api例程里跑,擦写正常,所以应该不是CMD文件问题;
2、用Flash_ToggleTest()测试频率,输出波形为30K,不是手册里提的10K,所以Flash Api的频率不对;请问这里的频率与哪里的设置相关?是PLL的设置吗?
折腾了好几天了,一直没解决这问题。希望得到答复,万分感谢!
Susan Yang:
为了更好地回复您的问题,请说明以下问题:
请问您在测试lab05b例程的时候,硬件是哪个开发板?只有28027的板子(自制板)?直接运行例程(不修改cmd文件)是否可以连接成功?
关于错误您可以看一下
software-dl.ti.com/…/ccsv7_debugging_jtag_connectivity_issues.html
,
user6301887:
自制板,主要是Flash api擦写问题,可以连接成功,但加上擦除flash的api函数,程序运行不正常
,
Susan Yang:
若是可以的话,请给出您的相关代码,谢谢
请先参考相关帖子
e2e.ti.com/…/200955
另外Flash_ToggleTest的话,不在lab05时测试正常吗?
,
user6301887:
你好,不在lab05b跑,在Flash2802x_API例程上跑正常,擦写flash都OK;
参考了您给出的帖子,还是找不到问题点;
我的只有PLL初始化是用lab05b的PLL初始化,没有修改,是否需要修改?
下面是我的程序,谢谢!
// system includes #include <math.h> #include "main.h" #include <stdio.h> // NULL is defined here#include "sw\solutions\instaspin_foc\boards\boostxldrv8305_revA\f28x\f2802xF\src\motor_ctr.h" #include "sw\solutions\instaspin_foc\boards\boostxldrv8305_revA\f28x\f2802xF\src\Flash2802x_API_Config.h" #include "sw\solutions\instaspin_foc\boards\boostxldrv8305_revA\f28x\f2802xF\src\Flash2802x_API_Library.h" #include "sw\solutions\instaspin_foc\boards\boostxldrv8305_revA\f28x\f2802xF\src\F2802x_SysCtrl.h"// System Control/Power Modes#ifdef FLASH #pragma CODE_SECTION(mainISR,"ramfuncs"); #endif// Include header files used in the main function#ifdef __cplusplus #pragma DATA_SECTION("FlashScalingVar"); #else #pragma DATA_SECTION(Flash_CPUScaleFactor, "FlashScalingVar"); #endif uint32_t Flash_CPUScaleFactor;#ifdef __cplusplus #pragma DATA_SECTION("FlashCallbackVar"); #else #pragma DATA_SECTION(Flash_CallbackPtr, "FlashCallbackVar"); #endif void (*Flash_CallbackPtr) (void);#ifdef __cplusplus #pragma DATA_SECTION("CsmRegsFile") #else #pragma DATA_SECTION(CsmRegs,"CsmRegsFile"); #endif volatile struct CSM_REGS CsmRegs;#ifdef __cplusplus #pragma DATA_SECTION("CsmPwlFile") #else #pragma DATA_SECTION(CsmPwl,"CsmPwlFile"); #endif volatile struct CSM_PWL CsmPwl;/*--- Global variables used to interface to the flash routines */ FLASH_ST FlashStatus;/*--- Callback function.Function specified by defining Flash_CallbackPtr */ void MyCallbackFunction(void); Uint32 MyCallbackCounter; // Just increment a counter in the callback function/*---------------------------------------------------------------------------Data/Program Buffer used for testing the flash API functions ---------------------------------------------------------------------------*/ #defineWORDS_IN_FLASH_BUFFER 0x100// Programming data buffer, Words Uint16Buffer[WORDS_IN_FLASH_BUFFER];/*---------------------------------------------------------------------------These key values are used to unlock the CSM by this exampleThey are defined in Example_Flash2802x_CsmKeys.asm --------------------------------------------------------------------------*/ extern Uint16 PRG_key0;//CSM Key values extern Uint16 PRG_key1; extern Uint16 PRG_key2; extern Uint16 PRG_key3; extern Uint16 PRG_key4; extern Uint16 PRG_key5; extern Uint16 PRG_key6; extern Uint16 PRG_key7;/*---------------------------------------------------------------------------Sector address info ---------------------------------------------------------------------------*/ typedef struct {Uint16 *StartAddr;Uint16 *EndAddr; } SECTOR;#define OTP_START_ADDR0x3D7800 #define OTP_END_ADDR0x3D7BFF#define FLASH_START_ADDR0x3F0000 #define FLASH_END_ADDR0x3F7FFFSECTOR Sector[4] = {(Uint16 *)0x3F6000,(Uint16 *)0x3F7FFF,(Uint16 *)0x3F4000,(Uint16 *)0x3F5FFF,(Uint16 *)0x3F2000,(Uint16 *)0x3F3FFF,(Uint16 *)0x3F0000,(Uint16 *)0x3F1FFF, };void main(void) {uint_least8_t estNumber = 0;//uint32_t timea;Uint16 Status;#ifdef FAST_ROM_V1p6uint_least8_t ctrlNumber = 1; #endif// Only used if running from FLASH// Note that the variable FLASH is defined by the project#ifdef FLASH// Copy time critical code and Flash setup code to RAM// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart// symbols are created by the linker. Refer to the linker files.//memCopy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);#endif// initialize the hardware abstraction layerhalHandle = HAL_init(&hal,sizeof(hal));//lab05b例程的初始化,没做修改// initialize the user parametersUSER_setParams(&gUserParams);// set the hardware abstraction layer parametersHAL_setParams(halHandle,&gUserParams);DINT;/*------------------------------------------------------------------Unlock the CSM.If the API functions are going to run in unsecured RAMthen the CSM must be unlocked in order for the flashAPI functions to access the flash.If the flash API functions are executed from secure memory(L0-L3) then this step is not required.------------------------------------------------------------------*/Status = Example_CsmUnlock();if(Status != STATUS_SUCCESS){Example_Error(Status);}EALLOW;Flash_CPUScaleFactor = SCALE_FACTOR;EDIS;EALLOW;Flash_CallbackPtr = &MyCallbackFunction;EDIS;MyCallbackCounter = 0;Example_CallFlashAPI();EINT;// Example: Toggle GPIO12Example_ToggleTest(12); } #pragma CODE_SECTION(Example_CallFlashAPI,"ramfuncs"); void Example_CallFlashAPI(void)Uint16Status;float32 Version;// Version of the API in floating pointUint16VersionHex;// Version of the API in decimal encoded hexVersionHex = Flash_APIVersionHex();if(VersionHex != 0x0201){// Unexpected API version// Make a decision based on this info.asm("ESTOP0");}Version = Flash_APIVersion();if(Version != (float32)2.01){// Unexpected API version// Make a decision based on this info.asm("ESTOP0");}//Status = Flash_Erase(SECTORD,&FlashStatus);//if(Status != STATUS_SUCCESS)//{//Example_Error(Status);//} }