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.

TMP117通过手机接收数据,高八位的数据一直为零

Other Parts Discussed in Thread: TMP117, CC2650, CC2650STK

采用的CC2650和tmp117利用I2C进行了通信,借鉴了CC2640R2的读取tmp117的代码,但最终在手机端采集到的数字丢失高八位数据,经过调试也没有得到改正,请问有什么办法定位问题吗?把相关代码附在下面。

定义广播数组

static uint8_t advertData[] =
{
// Flags; this sets the device to use limited discoverable
// mode (advertises for 30 seconds at a time) instead of general
// discoverable mode (advertises indefinitely)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// service UUID, to notify central devices what services are included
// in this peripheral
0x03, // length of this data
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
LO_UINT16(SENSORPROFILE_SERV_UUID),
HI_UINT16(SENSORPROFILE_SERV_UUID),

// Manufacturer specific data communicated here
0x03, // length of this data
GAP_ADTYPE_MANUFACTURER_SPECIFIC, // Manufacturer Specific Data
0x00, // Temp High
0x00 // Temp Low

}

初始化并开始单次测量(tmp117的数据读取函数和I2C的初始化省略,见tida 01624.c中的代码)

I2C_init();
// hGpioPin = PIN_open(&pinGpioState, radCtrlCfg_peripheral);
// PIN_registerIntCb(hGpioPin, SensorTag_callback);

uint8_t txBuffer[3];
uint8_t rxBuffer[2];
I2C_Transaction i2cTransaction;

/* Initializing the task */
sensorTaskInit();

/* Configure the TMP117 for One Shot conversion with an average of 8 */
txBuffer[0] = TMP117_OBJ_CONFIG;
txBuffer[1] = 0x0C;
txBuffer[2] = 0x20;
i2cTransaction.slaveAddress = Board_TMP_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 3;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;

/* Wait for the I2C access for configuration. If it fails
* then sleep for 1 second and try again. This is a must
* to do before reading the device. */
while(!(I2C_transfer(i2c, &i2cTransaction)))
{
//Display_printf(dispHandle, 0, 0, "I2C Cfg Fault");
}

Util_startClock(&periodicClock);

// Perform a read to flush the TMP117 power on value
sensorRead();

定义周期发送数据

if (events & SBP_PERIODIC_EVT)// add periodic event
{
uint16_t uiTempData;
// events &= ~SBP_PERIODIC_EVT;

//start timer again
Util_startClock(&periodicClock);

// Read the last converted temperature and then start the next
// temperature conversion.
uiTempData = sensorRead();

// Update the Auto Advertisement Data
advertData[9] = (uiTempData & 0xFF00) >> 8;
advertData[10] = uiTempData & 0xFF;
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);

// // Perform periodic application task
// SimplePeripheral_performPeriodicTask(uiTempData);
// Perform periodic application task
sensor_performPeriodicTask(uiTempData); // task period

进入到IAR的debug模式后,之前会顺利从BIOS_start()顺利跳转到task_init();中执行,但最近出现了死循环,debug提示stack pointer for CSTACK is outside the stack range.  上网搜索了很多之后,这种不影响程序,但影响我调试程序,查看taskfxn函数中温度变量值。

请问:

1、采用上述代码到CC2650中,存在什么问题,导致蓝牙发送时高八位数据丢失;

2、采用IAR的debug时,怎么操作可以避免进入BIOS_start()死循环,而进入到taskfxn函数中。