Questions and discussions about the software that runs on the TD RF module itself.
francois
 
Posts: 47
Joined: Tue Jun 16, 2015 6:13 am

I2C issue

by francois Sat Nov 07, 2015 8:33 am

Hi

I am trying to talk to an external temperature sensor over the i2c bus.

At the first write on the bus i have the following error message as a return of the I2C_Transfer() function:

"-3" meaning "Arbitration lost during transfer"

I initiate the com this way:

CMU_ClockEnable(cmuClock_I2C0, true);
GPIO_PinModeSet(gpioPortA, 0,gpioModeWiredAnd,1);
GPIO_PinModeSet(gpioPortA, 1, gpioModeWiredAnd, 1);

I2C0->ROUTE |= I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN;

const I2C_Init_TypeDef init = I2C_INIT_DEFAULT;
I2C_Init(I2C0, &init);

I2C_Enable(I2C0, true);

Do you see anything wrong here?

Thanks!
francois
 
Posts: 47
Joined: Tue Jun 16, 2015 6:13 am

Re: I2C issue

by francois Sat Nov 07, 2015 9:24 am

Problem resolved adding a pull up.
sigfoxsignal
 
Posts: 2
Joined: Thu Nov 03, 2016 5:04 pm

Re: I2C issue

by sigfoxsignal Mon Nov 14, 2016 11:14 pm

Hello everybody,

I have been trying for several days to interface my TD1208 to a HTU21D temperature/humidity sensor using I2C.

But I cannot succeed and feel desesperate.

I2C_Transfer() function always return -1.

I have put my oscilloscope on the SCL output of the TD1208 and it seems the output is always +3.3v.
I am using two 12kOhms resistors.

Here is my code :

// Configure needed clock to have I2C working
CMU_ClockEnable(cmuClock_I2C0, true);
CMU_ClockEnable(cmuClock_GPIO, true);

// Configure I/O pins for working as I2C - Output Open Drain
GPIO_PinModeSet(SCL_PORT, SCL_BIT, gpioModeWiredAnd, 1);
GPIO_PinModeSet(SDA_PORT, SDA_BIT, gpioModeWiredAnd, 1);
I2C0->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | _I2C_ROUTE_LOCATION_LOC0;

// Init the I2C with default param 100KHz
I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;
I2C_Init(I2C0, &i2cInit);

// Prepare for the transaction
I2C_TransferSeq_TypeDef i2cTransfert;
uint8_t command[1] = {0};
uint8_t values[3] = {0,0,0};
i2cTransfert.addr = HTU21D_ADDRESS;

// Send HUMD MEASURE command to HTU21D
i2cTransfert.flags = I2C_FLAG_WRITE;
command[0] = TRIGGER_HUMD_MEASURE_NOHOLD;
i2cTransfert.buf[0].len = 1;
i2cTransfert.buf[0].data = command;
int _status = I2C_TransferInit(I2C0, &i2cTransfert);
while ( _status == i2cTransferInProgress) {
_status = I2C_Transfer(I2C0);
}
// ===> At this point _status is -1


// Get the HUMD MEASURE data from HTU21D
i2cTransfert.flags = I2C_FLAG_READ;
i2cTransfert.buf[0].len = 3;
i2cTransfert.buf[0].data = values;
_status = I2C_TransferInit(I2C0, &i2cTransfert);
while ( _status == i2cTransferInProgress) {
_status = I2C_Transfer(I2C0);
}
// ===> At this point _status is -1

Do you know what is wrong or what I am missing ?
My feeling is that SCL and SDA are not well initiated.

Best regards,
JM Roque
User avatar
mstempin
 
Posts: 168
Joined: Thu May 07, 2015 9:24 am

Re: I2C issue

by mstempin Mon Nov 28, 2016 3:15 pm

It is difficult to tell what is going on. By chance, are you able to check with an oscilloscope?
Return to Firmware

Who is online

Users browsing this forum: No registered users and 26 guests