I am using CC2640. On a pin DIO_0 and DIO_1 is connected I2C bus (DIO_1 = SDA, DIO1 = SCL). On other side of I2C buss is power management chip.
What shall I do to start communicating with my I2C slave?
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.
Well... those topics do not solve my problems.
Lets start with simple questions. And built my project until communication is established between CC2640 and AS3701B (I want to connect those 2 HW modules via I2C).
About initialization.
Shall I modify existing BoardGpioInitTable? Or shall I create my own InitTable? Is it allowed to have 2 initializations?
I want to write to register located at address 0x09, value 0x74. This is part of my code:
void myInitPmu(void)
{
bool retVal;
uint8_t buffer[2];
buffer[0]=0x09; // register address
buffer[1]=0x74; // value which needs to be written in specified register
retVal = bspI2cWrite(buffer,2);
}
But, during compilation, I got an error:
unresolved symbol I2C_transfer, first referenced in <whole-program>
I see that function "bspI2cWrite" is calling "I2C_transfer".
You have to add I2C.c, I2c.h, I2CCC26XX.c, and I2CCC26XX.h into SimpleBLEPeripherial.
I added those includes in the same file where I send command to write into register. But the same error occured.
#include "bsp_i2c.h"
#include <ti/drivers/i2c/I2CCC26XX.h>
#include <ti/drivers/I2C.h>
...
void myInitPmu(void)
{
bool retVal;
uint8_t buffer[2];
buffer[0]=0x09; // register address
buffer[1]=0x74; // value which needs to be written in specified register
retVal = bspI2cWrite(buffer,2);
}
unresolved symbol I2C_transfer, first referenced in <whole-program>
Thank you for example code. I compare it with my code, and do following:
1) add into "init" function
bool retVal;
uint8_t buffer[2];
buffer[0]=0x09; // register address
buffer[1]=0x74; // value which needs to be written in specified register
retVal = bspI2cWrite(buffer,2);
2) added into Board.c
* ============================= I2C Begin=====================================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(I2C_config, ".const:I2C_config")
#pragma DATA_SECTION(i2cCC26xxHWAttrs, ".const:i2cCC26xxHWAttrs")
#endif
/* Include drivers */
#include <ti/drivers/i2c/I2CCC26XX.h>
/* 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,
.intNum = INT_I2C,
.powerMngrId = PERIPH_I2C0,
.sdaPin = MyBoard_I2C0_SDA0,
.sclPin = MyBoard_I2C0_SCL0,
}
};
const I2C_Config I2C_config[] = {
{&I2CCC26XX_fxnTable, &i2cCC26xxObjects[0], &i2cCC26xxHWAttrs[0]},
{NULL, NULL, NULL}
};
/*
* ========================== I2C end =========================================
*/
3) added into Board.h
#define MyBoard_I2C0_SDA0 IOID_0
#define MyBoard_I2C0_SCL0 IOID_1
And the error is the same.
unresolved symbol I2C_transfer, first referenced in <whole-program>
Since I don't use CCS, Let's go back to your latest problem using your own modification on CCS.
unresolved symbol I2C_transfer, first referenced in <whole-program>
This error should be caused by I2C.c not added correct into your CCS project. Please check this again.
Finally, I managed to find a solution.
I need to create directory "I2C" in my CCS project structure.
Than I added link to following files in that same directory ("I2C"):
C:\TI\tirtos_simplelink_2_11_01_09\packages\ti\drivers\I2C.c
C:\TI\tirtos_simplelink_2_11_01_09\packages\ti\drivers\I2C.h
C:\TI\tirtos_simplelink_2_11_01_09\packages\ti\drivers\i2c\I2CCC26XX.c
C:\TI\tirtos_simplelink_2_11_01_09\packages\ti\drivers\i2c\I2CCC26XX.h