Part Number:CC2640R2F
Tool/software: TI-RTOS
Hi,
I'm using a CC2640R2 on a custom board with multiple devices on one I2C bus, using TI-RTOS with IAR. I started my application from the Simple BLE Peripheral from the simplelink_cc2640r2_sdk_01_50_00_58 SDK. I only have one task running in my program.
Everything seemed to work fine (every devices on the bus working as expected), but now that I want to do something a little different, the program gets stuck after a while.
When an event is received in the SBP task, I'm starting to do a long loop that read/write data to the I2C devices, and write some output through UART. This loop last for more than 30 sec, but this wasn't a problem.
The problem arised when I added communication with an Si514 in this loop. The program works as expected but suddenly stop after a rather regular time.
I tried reducing I2C bus bitrate (400KHz --> 100KHz) but it didn't solve the problem. I tried to enlarge the app stack size, but it didn't work either.
What seems to prevent the program to stop is to remove some of the I2C transactions. Below is a part of the code that is executed inside the loop.
static bool si514_write_reg(uint8_t reg, uint8_t *data, uint8_t len)
{
uint8_t buff[32] = {reg};
if(len >= sizeof(buff))
{
return false;
}
memcpy((buff + 1), data, len);
I2C_Transaction i2cTransaction;
i2cTransaction.slaveAddress = Board_SI514_ADDR;
i2cTransaction.writeBuf = buff;
i2cTransaction.writeCount = (len + 1);
i2cTransaction.readBuf = NULL;
i2cTransaction.readCount = 0;
return I2C_transfer(i2c, &i2cTransaction);
}
...Somewhere in my long loop
{
uint8_t buff[7] = {0};
buff[0] = m_frac;
buff[1] = (m_frac >> 8);
buff[2] = (m_frac >> 16);
buff[3] = ((m_frac >> 24) | (m_int << 5));
buff[4] = (m_int >> 3);
buff[5] = hs_div;
buff[6] = ((hs_div >> 8) | (ls_div_bits << 4));
//It seems that the following 2 I2C write stuck the program after a while ...
if(!si514_write_reg(SI514_REG_HS_DIV, (buff + 5), 2))
{
return false;
}
if(!si514_write_reg(SI514_REG_M_FRAC1, buff, 5))
{
return false;
}
}
I tried to comment out either of the two si514_write_reg and then the program doesn't get stuck. I also tried to add a delay between the two si514_write_reg, but this doesn't seem to change anything.
Is there something I'm missing ? I don't understand why this would work at first but block after a while.
If you need any more information in order to help me, please just ask, I'll answer as soon as possible.
Best regards,
Mehdi