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.

[参考译文] TMS320F280049C:代码未按 CLA 的预期进行调试

Guru**** 2553450 points
Other Parts Discussed in Thread: TMS320F280049C, CCSTUDIO, C2000WARE

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1380996/tms320f280049c-code-is-not-debugging-as-expected-for-cla

器件型号:TMS320F280049C
Thread 中讨论的其他器件: CCStudioC2000WARE

工具与软件:

大家好、团队成员:

我编写了一个 CLA 代码、调用一个测试用例函数并进行一些转换。 代码正在生成、调试未按预期在 CLA 中进行。 2到3个函数调用后、调试将转到 asm 文件(看门狗)。

这里、我附加了 CLA 文件和主文件。

如果需要任何文件/信息、请告诉我。

谢谢。此致、

Rajesh

/*
Filename: main.c
*/

#include "device.h"
void breakfunc();

int main(void)
{
    Device_setup();


       //
        // Enable ADC interrupt
        //
        ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
    #ifndef CLA_CPU
        Interrupt_enable(INT_ADCA1);
    #endif

        //
        // Enable the clock to synchronously enable all the ePWMs
        //
       SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

       breakfunc();
//while(1);
    return 0;
}

void breakfunc()
{
    volatile int bp=0;
}

/*
Filename: test.cla
*/

#include <stdio.h>

#include <device.h>

#define MSG_SIZE 32

int testbed_out;
int history_in_target;
int fileid;
int Configured;
char message[MSG_SIZE];
int exit_reached;
int iter_message;
char *qqqqone;
int test_return;

void upload (void)
{
	  int iter;
      iter_message=0;
      for ( iter=0; iter<MSG_SIZE; iter++ ) {
           message[iter] = 0;
      }
}

void port_init (void)
{
	  int i;
	  Configured=0;
      qqqqone="%6d%6d\n";
      for( i=0;i<MSG_SIZE;i++)
      {
      message[i]=0;
      }
	  upload();
	  iter_message=0;
	  message[0]=0;
	  Configured=1;
}

void c_exit()
{
	Configured = 1;
}

void port_close()
{
	exit_reached=1;
	upload();
	c_exit();
}

int port_configured (void) {
  return Configured;
}

int port_open (void) {
  fileid = 1;
  /* 
   * Protect against the case with just a single main and in white box
   * where the port can get initialised twice 
   */
  if ( port_configured() == 0 ) {
    port_init();
  }
  /* Need to stop ldra_port_close from being optimised out */
  if ( port_configured() == 0 ) {
    port_close();
  }
  return fileid;
}

void port_write(const char *pMsg)
{
	if ( pMsg != 0 ) {
    /* Output characters in string until 0 terminator */
    while (*pMsg != 0 ) {
      /* Write characters to the buffer */
      message[iter_message] = *pMsg;
      iter_message++;
        
      if ( iter_message >= MSG_SIZE ) {
        /* Upload the entire buffer in one go when full */
        upload();
      }
      /* Point to next character */
      pMsg++;
    }
    message[iter_message]=0;
  }
}

int port_initialisation(void)
{
/* ****4 New test case initialisation */

  testbed_out = port_open();
  return 1;

} /* end of port_initialisation */

void output (char *fmt,int start,int new_line)
{
  port_write (fmt);

  if (new_line)
  {
    port_write ("\n");
  }
}

char abs (const int n) 
{
  int v;
  if ( n < 0 ) {
    v = -n;
  } else {
    v = n;
  }
  return v;
}

void char_push_front(char* buf, int i, const char add)
{
  /* Move any previous values */
  int k = i-1;

  while (k >= 0) {
    buf[i] = buf[k];
    i--;
    k--;
  }

  /* Add the next value */
  buf[0]=add;
}

int int_sprintf(char* buf, const char *fmt, const int ap)
{
  int i = 0;
  int ret = 0;
  int value = ap;

  /* null terminate the array */
  buf[i]=0;
  i++;

  if (value == 0) {
    char_push_front(buf,i,'0');
    i++;
  }

  while (value != 0) {
    /* Compute the next character  */
    char next = abs(value % 10) + '0';

    /* Add to the existing array */
    char_push_front(buf,i,next);

    /* Calculate the next step */
    value = value / 10;
    i++;
  }

  /* If the original value was negative, add the sign */
  if (ap < 0) {
    char_push_front(buf,i,'-');
    i++;
  }

  /* return number of printed characters minus the null terminator */
  ret = i-1;
  return ret;
}

int signed_int_convert(const signed int value, char* res)
{
	int_sprintf (res,"%d", value);
	return 1;
}

int int_strcmp (const char* a, const char* b)
{
  int ret = 0;

  if (a == (const char*)(0) && b == (const char*)(0)) {
    ret = 0;
  } else if (a == (const char*)(0)) {
    ret = 1;
  } else if (b == (const char*)(0)) {
    ret = -1;
  } else {
    while (!(ret = *(unsigned char*)a - *(unsigned char*)b) && *b) {
      ++a;
      ++b;
    }

    if (ret < 0 ) {
      ret = -1;
    } else if (ret > 0) {
      ret = 1;
    }
  }
  return ret;
}

int string_compare (char* a, char* b)
{
  int equal = 0;

  if (a == (char*)(0) && b == (char*)(0)) {
    equal = 1;
  } else if (a != (char*)(0) && b != (char*)(0)) {
    equal = int_strcmp(a,b) == 0;
  }
  return equal;
}

int int_convert(int expected_value,int actual_value,char * name,
                             char * svalue,char df,int convert,int compare,
                             int convert_ok,char * expstr)
{
  char testbed_buff[64];
  int variable_converted = 1;
  int variable_passed = 1;
  int var_exception_raised = 0;
  char str[3];
  int saved_history_in_target = history_in_target;
  testbed_buff[0] = '\0';
  str[0] = df;
  str[1] = ' ';
  str[2] = '\0';
    if (convert == 1)
    {
      variable_converted = signed_int_convert (actual_value,testbed_buff);
    }
  if (var_exception_raised == 1)
  {
      output (name,0,1);
      variable_passed = 0;
  }
  else
  {
    if (convert > 0)
    {
       output ("pass",0,1);
    }
    else
    {
       output ("fail",0,1);
    }
    if (variable_converted == 1)
    {
        variable_passed = 0;
        if (compare == 1)
        {
          if (expected_value != actual_value)
          {
            variable_passed = 0;
          }
          else
          {
            variable_passed = 1;
          }
        }
    }
    else
    {
      if (convert_ok == 0)
      {
        variable_passed = string_compare (expstr,testbed_buff);
      }
      else
      {
        variable_passed = 0;
      }
    }
    if (variable_passed == 1)
    {
      output ("P ",1,0);
    }
    else
    {
      output ("F ",1,0);
    }
    history_in_target = 0;
    if (variable_converted == 1)
    {
      output ("V",0,0);
    }
    else
    {
      output ("F",0,0);
    }
    if (convert > 0)
    {
      output (" ",0,0);
      output (testbed_buff,0,0);
    }
    output ("",0,1);
    history_in_target = saved_history_in_target;
  }
  return variable_passed;
} 

int unit_test()
{
	return 0;
}

int test_case_1()
{
	int passed=1;
	int exception_raised=1;
	output("need to print",1,1);
	test_return=unit_test();
	if (exception_raised == 1)
    {
       output ("pass",1,1);
    }
    else
    {
       output ("fail",1,1);
    }
	if (int_convert(test_return,test_return,"%",
                        "",'O',1,1,
                        1,"") == 0)
    {
       passed = 0;
    }
	return passed;
}

void initialise()
{
    testbed_out=0;
    fileid=0;
	history_in_target = 1;
	Configured=0;
}

void test_cla()
{
    //
    // Uncomment to halt and debug
  __mdebugstop();
 initialise();
  if (port_initialisation())
  {
/*
 * Execute new test case
 */
    test_case_1 ();
  }
  port_close();
  return ;
}

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

    尊敬的 Kandala:

    您能解释一下这种设置吗?  

    你有一个 CLA 任务在.cla 文件中定义- CLA 任务使用了什么触发器?

    你的代码是否 基于其中一个 CLA 示例?

    此致、

    Delaney

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

    尊敬的 Delaney:

    感谢您的答复。

    我在此附上整个项目文件夹、其中包含目标配置文件和所有其他有关项目设置的信息。

    是、根据为 TMS320F280049C 提供的 CLA 示例、创建附加的工程。

    我在 CLA 中又创建了2个具有1或2个函数的项目、这些项目运行正常。

    如果您需要任何其他信息、请告诉我。

    谢谢。此致、

    Rajesh。

    CLA 代码正常工作和无法正常工作

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

    尊敬的 Kandala:

    感谢您的答复。 您能在此处描述/总结您的设置吗? 通常、直接代码调试不在我们可以在 E2E 上提供的范围内。 但是、如果您更详细地描述您的设置和/或问题、我可以看到是否有任何东西听起来配置错误、并尝试提供一些指导。

    此致、

    Delaney

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

    尊敬的 Delaney:

    设置和设置详细信息可以在附加的链接(Prev. Reply)中找到、其中.ccsproject、设置、.cproject 等、适用于工作项目和非工作项目。

    您能告诉我您还需要哪些其他设置/设置详细信息以便我提供吗?

    我实际遇到的问题是、一个项目的 CLA 调试不能正常进行、而另一个项目和调试设置相同。

    如果需要、我可以安排 Webex 或 Teams 与您会面、以展示相关问题。

    我的设置详细信息:

      将 CCStudio 版本12.7.1.00001与 C2000编译器和 C2000Ware_5_02_00_00配合使用以获得硬件支持。

      TMS320F280049C 硬件实现的、并使用 ADC 中断调用 CLA。

    附加用于显示两个工程(工作和非工作)的设置文件的链接:

    cla_settings_files_with_project

    此致、

    Rajesh

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

    尊敬的 Rajesh:

    感谢您提供演示视频录制。 观看完视频后、我认为我看到了这个问题。 通常、在 CLA 程序中、您希望避免过多的嵌套函数调用、因为这会减慢 CLA 程序的速度、并且暂存区(可视为 CLA 的堆栈)可能会溢出。 在旧版本的 CLA 外设中、最多允许两个函数调用、但 F28004x 的 CLA 上已删除此要求。

    看起来port_init()、当调用函数时、暂存区帧绝不会放置在暂存区存储器中(意味着它可能已满)、并且 CLA 不知道如何从函数调用返回、因为暂存区中没有返回地址。 我建议删除嵌套函数调用、并将程序限制为一个级别的函数嵌套最大值(CLA 可以分支到一个任务、而该任务可以调用另一个函数、然后返回)。 例如、您可以port_initialisation()在任务内部调用、但包含该函数中的所有代码、并避免跳转到中的任何其他函数port_initialisation()。 如果问题得到解决、请尝试执行此操作、然后对该回答投赞成票。

    此致、

    Delaney

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

    尊敬的 Delaney:

    但在我的映射文件中、我可以在暂存区存储器中看到所有函数。 您可以在 prev 中找到映射文件。 附加链接。 我还观察到其中一个项目发生了嵌套函数调用。

    附加暂存区存储器的屏幕截图供您参考。

    此致、

    Rajesh

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

    尊敬的 Delaney:

    感谢您在嵌套函数输入方面的帮助(本例中适用)。

    我按照您的输入来了解嵌套函数、并尝试减小嵌套函数。 这样、我就可以进行调试、直到我在某个级别检查了 IF 条件下的数学计算

        如果((值% 10)> 0)

    在这个特定位置、调试将到某个位置、而不会返回到函数。

    附加调试的代码和视频以供您参考。

    e2e.ti.com/.../CLA_5F00_debugging_5F00_math_5F00_clac.mp4

    #include <stdio.h>
    
    #include <device.h>
    
    void test_cla()
    {
        //
        // Uncomment to halt and debug
      __mdebugstop();
    
      int value = 35, next;
    	  	 if ( (value % 10) < 0 ) {
    	  	       next = -(value % 10) + '0';
    	  	     } else {
    	  	       next = (value % 10) + '0';
    	  	     }
    }
    

    其余所有设置与工程和调试相同。

    此致、

    Rajesh

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

    尊敬的 Rajesh:

    很高兴听到我之前关于嵌套函数的建议很有帮助。  

    对于此问题、这意味着 CCS 正在查找源文件但找不到它。 只是为了验证、第11行上的警告是什么?

    可 从.cla 文件中使用模数(%)功能、但让我咨询另一位 CLA 专家、看看是否需要任何其他包含来使其正常工作。

    此致、

    Delaney

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

    尊敬的 Delaney:

    您是否为上述模数运算查询找到了任何解决方案?

    此致、

    Rajesh

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

    尊敬的 Kandala:

    由于周一的飓风贝丽尔袭击德克萨斯州,该团队目前没有电力,因此我没有机会咨询另一位专家。 一旦我们恢复正常运行并在办公室工作、我会立即回复您。 由此给您带来的不便、我深表歉意。

    此致、

    Delaney

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

    尊敬的 Kandala:

    很抱歉耽误你的时间。 您是否可以尝试点击"Locate File"并导航至 CCS 编译器安装文件夹: c:/ti/ccs1270/ccs/tools/compiler/ti-cgt-c2000_22.6.1.LTS? 这样 CCS 就能在您本地 PC 上找到模数运算源代码、并能让您在调试器中单步执行该行。 此 CCS 错误并不意味着代码存在任何问题、而是意味着 CCS 本身不知道如何定位正确的文件、以便在调试时向您展示代码执行情况。

    此致、

    Delaney