Quantcast
Channel: Amplifiers forum - Recent Threads
Viewing all articles
Browse latest Browse all 18870

Integrating INA219 & CC2650 - I2C Bus

$
0
0

Hi

I am working on integrating INA219& CC2650 through the I2C, I am following the guidelines given in the datasheet for INA219. I want to go step by step, as I understand from the datasheet of INA219, the first task is to write into the calibration register '05h'. Assuming a 0.1 ohm shunt resistor, In order to configure the maximum I/P voltage & current to 2A and 26V after some calculations as per datasheet I came up with a value of 4096 which in hexadecimal is 1000. Now, when I write 1000 in the calibration register, I can now expect values from the current and power registers(adress 04H & 03H) respectively. I have hence modified the TI temperature sensor example code(mainly the taskFXN) as shown below to read the current and power registers. However I am not successfull!, can someone please point out the mistake in my code. My Code is as given below.

Void taskFxn(UArg arg0, UArg arg1)
{
// unsigned int i;
// uint16_t temperature;
uint8_t txBuffer[4];
uint8_t rxBuffer[3];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;

/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}

/* Point to the T ambient register and read its 2 bytes */
txBuffer[0] = 0x05; // Calibration Register Address
txBuffer[1] = 0x1000; // Value written onto the calibration register- 4096(0x1000) for 32V,2A configuration
txBuffer[2] = 0x04; //Current Register address
txBuffer[3] = 0x03; //Power Register address
// i2cTransaction.slaveAddress = Board_TMP006_ADDR;
i2cTransaction.slaveAddress = 0x40; //address of INA219 foe A0, A1 grounded
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
if (I2C_transfer(i2c, &i2cTransaction)){
System_printf("Current: %x W \n", rxBuffer[0]);
System_printf("Power: %x A \n", rxBuffer[1]);
} else {
System_printf("Read/write fail!\n");

System_flush();
Task_sleep(1000000 / Clock_tickPeriod);
}

I2C_close(i2c);
System_printf("I2C closed!\n");

System_flush();
}

My Console port results are as follows:

[Cortex_M3_0] Starting the I2C example
System provider is set to SysMin. Halt the target to view any SysMin contents in ROV.
I2C Initialized!
Read fail!
I2C closed!

Can Some please point out the mistake in my code.

Thanks in advance for the help.


Viewing all articles
Browse latest Browse all 18870

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>