在TMS570LS31HDK的video中,关于视频HERCULES12-bitADC.wmv中的第08:30到09:32之间的粘贴的代码看不清楚,麻烦技术工程师帮助解答一下,或者写一下视频中补充的代码。谢谢
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.
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 */}
有问题我们再交流,谢谢!
Bill,
您可以重新安装下CCS的Terminal小插件,安装方法请参考如下链接: http://processors.wiki.ti.com/index.php/How_to_install_the_terminal_plugin_in_CCSv5
当然,您也可以下载串口调试助手来与开发板通信,这种小工具很容易下载到,谢谢!