请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:LAUNCHXL-CC1310 嗨、团队:
我目前遇到一些问题,需要寻求帮助。 我现在计划使用 TI15.4的收集器和传感器例程发送收集到的 ADC 数据。 我计划一次发送100个 ADC 数据、因此我将使用时钟例程生成一个计时器、每10ms 收集一个 ADC 数据、并将 ADC 数据存储在一个包含100个元素的定义数组中。 然而、当我从传感器向收集器发送数据时、收集器端接收的数据全部为零(我采集的 ADC 具有3.3V 的电压)。 我想问一下原因在哪方面、下面的代码是:
int main(void)
{
Task_Params taskParams;
Clock_Params clkParams;
#ifndef USE_DEFAULT_USER_CFG
macUser0Cfg[0].pAssertFP = macHalAssertHandler;
#endif
#if ((CONFIG_RANGE_EXT_MODE == APIMAC_HIGH_GAIN_MODE) && \
defined(DeviceFamily_CC13X0) && !defined(FREQ_2_4G))
macUser0Cfg[0].pSetRE = Board_Palna_initialize;
#endif
/*
Initialization for board related stuff such as LEDs
following TI-RTOS convention
*/
PIN_init(BoardGpioInitTable);
#ifdef FEATURE_BLE_OAD
/* If FEATURE_BLE_OAD is enabled, look for a left button
* press on reset. This indicates to revert to some
* factory image
*/
if(!PIN_getInputValue(Board_PIN_BUTTON0))
{
OAD_markSwitch();
}
#endif /* FEATURE_BLE_OAD */
#if defined(POWER_MEAS)
/* Disable external flash for power measurements */
Board_shutDownExtFlash();
#endif
#if defined(FEATURE_BLE_OAD) || defined(FEATURE_NATIVE_OAD)
SPI_init();
#endif
#ifndef POWER_MEAS
#if defined(BOARD_DISPLAY_USE_UART)
/* Enable System_printf(..) UART output */
UART_init();
UART_Params_init(&uartParams);
#ifndef TIMAC_AGAMA_FPGA
uartParams.baudRate = 115200;
#else
uartParams.baudRate = 460800;
#endif
UartPrintf_init(UART_open(Board_UART0, &uartParams));
#endif /* BOARD_DISPLAY_USE_UART */
#endif
Display_init();
#ifdef OSAL_PORT2TIRTOS
_macTaskId = macTaskInit(macUser0Cfg);
#endif
ADC_init();
/* Configure task. */
Clock_Params_init(&clkParams);
clkParams.period = 10000/Clock_tickPeriod;
clkParams.startFlag = TRUE;
/* Construct a periodic Clock Instance */
Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
5000/Clock_tickPeriod, &clkParams);
Task_Params_init(&taskParams);
taskParams.stack = appTaskStack;
taskParams.stackSize = APP_TASK_STACK_SIZE;
taskParams.priority = APP_TASK_PRIORITY;
Task_construct(&appTask, appTaskFxn, &taskParams, NULL);
#ifdef DEBUG_SW_TRACE
IOCPortConfigureSet(IOID_8, IOC_PORT_RFC_TRC, IOC_STD_OUTPUT
| IOC_CURRENT_4MA | IOC_SLEW_ENABLE);
#endif /* DEBUG_SW_TRACE */
clk2Handle = Clock_handle(&clk0Struct);
Clock_start(clk2Handle);
BIOS_start(); /* enable interrupts and start SYS/BIOS */
return (0);
}
//ADC acquisition function
//Send the collected ADC data in this function
//ambienceTemp[ADC_SAMPLE_COUNT_t] 中,
//this is to modify the temperature data in the original routine to an array containing 100 elements
Void clk0Fxn(UArg arg0)
{
UInt32 time;
Smsgs_tempSensorField_t temp;
if(ADC_inint_flag == 0){
ADC_inint_flag = 1;
ADC_Params_init(¶ms);
adc = ADC_open(Board_ADC1, ¶ms);
if (adc == NULL) {
Display_printf(display, 0, 0, "Error initializing ADC0\n");
Display_print1(display, 0, 0, "ADC_inint_flag:%d",ADC_inint_flag);
while (1);
}
else{
Display_printf(display, 0, 0, "Success initializing ADC0\n");
}
}
else{
/* Blocking mode conversion */
if(ADC_SAMPLE_COUNT_t != ADC_SAMPLE_COUNT){
ADC_SAMPLE_COUNT_t++;
res = ADC_convert(adc,&temp.ambienceTemp[ADC_SAMPLE_COUNT_t]);
}
else{
ADC_SAMPLE_COUNT_t=1;
res = ADC_convert(adc, &temp.ambienceTemp[ADC_SAMPLE_COUNT_t]);
}
if (res == ADC_STATUS_SUCCESS) {
time = Clock_getTicks();
//System_printf("System time in clk0Fxn = %lu\n", (ULong)time);
LCD_WRITE_STRING_VALUE("ADC_DATA:",&temp.ambienceTemp[ADC_SAMPLE_COUNT_t], 16, 5);
}
else {
Display_printf(display, 0, 0, "ADC convert failed!\n");
}
}
}
//Modified array structure
typedef struct _Smsgs_tempsensorfield_t
{
/*!
Ambience Chip Temperature - each value represents a 0.01 C
degree, so a value of 2475 represents 24.75 C.
*/
uint16_t ambienceTemp[100];
/*!
Object Temperature - each value represents a 0.01 C
degree, so a value of 2475 represents 24.75 C.
*/
//int16_t objectTemp;
} Smsgs_tempSensorField_t;
//sensor
//Build and send data fields,
//In this program, responsible for sending the collected 100 ADC frames into data packets
static bool sendSensorMessage(ApiMac_sAddr_t *pDstAddr, Smsgs_sensorMsg_t *pMsg)
{
bool ret = false;
uint8_t *pMsgBuf;
uint16_t len = SMSGS_BASIC_SENSOR_LEN;
int cnt=0;
/* Figure out the length */
if(pMsg->frameControl & Smsgs_dataFields_tempSensor)
{
len += SMSGS_SENSOR_TEMP_LEN;
}
if(pMsg->frameControl & Smsgs_dataFields_lightSensor)
{
len += SMSGS_SENSOR_LIGHT_LEN;
}
if(pMsg->frameControl & Smsgs_dataFields_humiditySensor)
{
len += SMSGS_SENSOR_HUMIDITY_LEN;
}
if(pMsg->frameControl & Smsgs_dataFields_msgStats)
{
//len += SMSGS_SENSOR_MSG_STATS_LEN;
len += sizeof(Smsgs_msgStatsField_t);
}
if(pMsg->frameControl & Smsgs_dataFields_configSettings)
{
len += SMSGS_SENSOR_CONFIG_SETTINGS_LEN;
}
pMsgBuf = (uint8_t *)Ssf_malloc(len);
if(pMsgBuf)
{
uint8_t *pBuf = pMsgBuf;
*pBuf++ = (uint8_t)Smsgs_cmdIds_sensorData;
memcpy(pBuf, pMsg->extAddress, SMGS_SENSOR_EXTADDR_LEN);
pBuf += SMGS_SENSOR_EXTADDR_LEN;
pBuf = Util_bufferUint16(pBuf,pMsg->frameControl);
/* Buffer data in order of frameControl mask, starting with LSB */
if(pMsg->frameControl & Smsgs_dataFields_tempSensor)
{
for(int i=0;i<100;i++){
cnt++;
pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.ambienceTemp[cnt]);
}
//pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.ambienceTemp);
//pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.objectTemp);
}
if(pMsg->frameControl & Smsgs_dataFields_lightSensor)
{
pBuf = Util_bufferUint16(pBuf, pMsg->lightSensor.rawData);
}
if(pMsg->frameControl & Smsgs_dataFields_humiditySensor)
{
pBuf = Util_bufferUint16(pBuf, pMsg->humiditySensor.temp);
pBuf = Util_bufferUint16(pBuf, pMsg->humiditySensor.humidity);
}
if(pMsg->frameControl & Smsgs_dataFields_msgStats)
{
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinAttempts);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinFails);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.msgsAttempted);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.msgsSent);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.trackingRequests);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.trackingResponseAttempts);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.trackingResponseSent);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.configRequests);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.configResponseAttempts);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.configResponseSent);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.channelAccessFailures);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.macAckFailures);
pBuf = Util_bufferUint16(pBuf,
pMsg->msgStats.otherDataRequestFailures);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.syncLossIndications);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.rxDecryptFailures);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.txEncryptFailures);
pBuf = Util_bufferUint16(pBuf, Ssf_resetCount);
pBuf = Util_bufferUint16(pBuf, Ssf_resetReseason);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinTime);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.interimDelay);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.numBroadcastMsgRcvd);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.numBroadcastMsglost);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.avgE2EDelay);
pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.worstCaseE2EDelay);
}
if(pMsg->frameControl & Smsgs_dataFields_configSettings)
{
pBuf = Util_bufferUint32(pBuf,
pMsg->configSettings.reportingInterval);
pBuf = Util_bufferUint32(pBuf,
pMsg->configSettings.pollingInterval);
}
ret = Sensor_sendMsg(Smsgs_cmdIds_sensorData, pDstAddr, true, len, pMsgBuf);
if(ret == true){
LCD_WRITE_STRING("Data Success Send.................", 2);
}
else{
LCD_WRITE_STRING("Data Success Failed", 2);
}
Ssf_free(pMsgBuf);
}
return (ret);
}
目前,问题出在阵列的接收缓存端。
ADC‘读取数据、但在缓存"empSensor.tempSensor.ambientetp"数组后、数组中的值为0