Other Parts Discussed in Thread: SYSBIOS, CC2650
Tool/software: TI-RTOS
Hi,
As described in serval posts on this forum the I2C need a bit of effort to get working on the CC2640 platform.
So as described in several posts I've added this to board.h (these are the pins I'm using):
#define Board_I2C0_SDA0 IOID_8
#define Board_I2C0_SCL0 IOID_9
Pins IOID_8 and IOID_9 are not being used by anything else (like SPI) in the included board.h.
And I've added this code to board.c:
// Add missing 12C structures
#include <ti/drivers/i2c/I2CCC26XX.h>
#include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
#define CC2650_I2CCOUNT 1
#define Board_I2C0_SDA0 IOID_8
#define Board_I2C0_SCL0 IOID_9
/* I2C objects */
I2CCC26XX_Object i2cCC26xxObjects[CC2650_I2CCOUNT];
/* I2C configuration structure, describing which pins are to be used */
const I2CCC26XX_HWAttrs i2cCC26xxHWAttrs[CC2650_I2CCOUNT] = {
{
.baseAddr = I2C0_BASE,
.powerMngrId = PERIPH_I2C0,
.sdaPin = Board_I2C0_SDA0,
.sclPin = Board_I2C0_SCL0,
.intNum = INT_I2C_IRQ,
.intPriority = (~0)
}
};
const I2C_Config I2C_config[] = {
{&I2CCC26XX_fxnTable, &i2cCC26xxObjects[0], &i2cCC26xxHWAttrs[0]},
{NULL, NULL, NULL}
};
I'm calling I2C_init() before BIOS_start() when starting up the program.
The code dies inside TI_TROS on calling I2C_open() from this code:
I2C_Params_init(¶ms);
params.bitRate = I2C_400kHz;
params.transferMode = I2C_MODE_BLOCKING;
i2cHandle = I2C_open(CC2650_I2C0, ¶ms);
The error happens inside I2CCC26XX_initHw when it trys to call I2CMasterInitExpClk.
static void I2CCC26XX_initHw(I2C_Handle handle) {
I2CCC26XX_Object *object;
I2CCC26XX_HWAttrs const *hwAttrs;
Types_FreqHz freq;
/* Get the pointer to the object and hwAttrs */
object = handle->object;
hwAttrs = handle->hwAttrs;
/* Set the I2C configuration */
BIOS_getCpuFreq(&freq);
I2CMasterInitExpClk(hwAttrs->baseAddr, freq.lo, bitRate[object->bitRate]);
object->bitrate contains the correct value before the call to BIOS_getCpuFreq, but after that call it has a value of 80560 which is obviously out of range.
Anyone have any idea to what might be going on / how to fix this?
Thanks,
Justin