Part Number:LAUNCHXL-CC1350
Tool/software:TI-RTOS
Hi TI Experts,
I would like to read the EEPROM with CC1350 Launchxl using I2C but there is no respond.
I tried in SPI mode driver and it is ok.
I modified the coding according to cc1350"i2ctmp007.c"
Is there any problem with the coding?
* ======== i2ctmp007.c ========
*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/I2C.h>
/* Example/Board Header files */
#include "Board.h"
#define TASKSTACKSIZE 2000
/* Global memory storage for a PIN_Config table */
static PIN_State ledPinState;
/*
* Application LED pin configuration table:
* - All LEDs board LEDs are off.
*/
PIN_Config ledPinTable[] = {
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
// Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
Void taskFxn(UArg arg0, UArg arg1)
{
uint8_t txBuffer[2];
uint8_t rxBuffer[2];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
Bool transferOK;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.transferMode = I2C_MODE_BLOCKING;
// i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C0, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
/*write 0x45 into address 0x00*/
txBuffer[0] = 0x00; // word address: 0x00
txBuffer[1] = 0x45; // data: 0x45
i2cTransaction.slaveAddress = 0xA0; //slave write address: 0xA0
i2cTransaction.writeBuf = &txBuffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = NULL;
i2cTransaction.readCount = 0;
transferOK = I2C_transfer(i2c, &i2cTransaction);
i2cTransaction.slaveAddress = 0xA1; //slave read address: 0xA1
i2cTransaction.writeBuf = NULL;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = &rxBuffer;
i2cTransaction.readCount = 1;
transferOK = I2C_transfer(i2c, &i2cTransaction);
if (!transferOK) {
System_printf("data: %d \n", rxBuffer[0]);
}
System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
}
/*
* ======== main ========
*/
int main(void)
{
PIN_Handle ledPinHandle;
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
Board_initI2C();
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)taskFxn, &taskParams, NULL);
/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, ledPinTable);
if(!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}
PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
System_printf("Starting the I2C example\nSystem provider is set to SysMin."
" Halt the target to view any SysMin contents in ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
/* Start BIOS */
BIOS_start();
return (0);
}
Please advice.
Thank,
Teach Me