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.

TMS570LS31HDK的video中的添加的代码是什么?ADC的

在TMS570LS31HDK的video中,关于视频HERCULES12-bitADC.wmv中的第08:30到09:32之间的粘贴的代码看不清楚,麻烦技术工程师帮助解答一下,或者写一下视频中补充的代码。谢谢

  • Hi Bill,

             您需要的代码如下所示:

    /* USER CODE BEGIN (0) */

    #include "sci.h"

    #include "adc.h"

    #include "stdlib.h"

    unsigned char command[8];

    /* USER CODE END */


    void main(void)

    {/* USER CODE BEGIN (3) */

      adcData_t adc_data; //ADC Data Structure

      adcData_t *adc_data_ptr = &adc_data; //ADC Data Pointer

      unsigned int NumberOfChars, value; //Declare variables

      sciInit(); //Initializes the SCI (UART) module

      adcInit(); //Initializes the ADC module

      while(1)  // Loop to acquire and send ADC sample data via the SCI (UART)

      {

        adcStartConversion(adcREG1, 1U);  //Start ADC conversion

        while(!adcIsConversionComplete(adcREG1, 1U)); //Wait for ADC conversion

        adcGetData(adcREG1, 1U, adc_data_ptr); //Store conversion into ADC pointer

        value = (unsigned int)adc_data_ptr->value;

        NumberOfChars = ltoa(value,(char *)command);

        sciSend(scilinREG, 2, (unsigned char *)"0x"); //Sends '0x' hex designation chars

        sciSend(scilinREG, NumberOfChars, command); //Sends the ambient light sensor data

        sciSend(scilinREG, 2, (unsigned char *)"\r\n"); //Sends new line character

      }

    /* USER CODE END */}

    有问题我们再交流,谢谢!

  • 依据视频在CCS中进行debug程序时候,总是出现这个问题,选择了端口serial,以及对应的COM口, 三种encoding设置也都不行, ,其他配置是 ,不知道这是什么原因呢。

  • Bill,

    您好,请问您把terminal 关掉,debug程序能够通过吗?

  • 当删除掉Terminal后,就可以顺利Debug。请问这是为什么呢?没有Terminal的话如何检测ADC是否正常啊?

  • Bill,

    您可以重新安装下CCS的Terminal小插件,安装方法请参考如下链接: http://processors.wiki.ti.com/index.php/How_to_install_the_terminal_plugin_in_CCSv5

    当然,您也可以下载串口调试助手来与开发板通信,这种小工具很容易下载到,谢谢!

  • 刚刚建立了一个QQ群,关于TMS570开发板的交流群,大家可以进来一起讨论。群号:301046097