Part Number: MSP430FR5969
Tool/software: TI-RTOS
Hi,
We are using Texas Instruments' CCS6.2.0 program,
the MCU MSP430FR5969, and also a Bosh BME280 sensor,
which is connected by I2C to MCU under TI-RTOS 2.20 communcations system and XDCtools 3.32.0.6.
At CC6.2.0 program we have downloaded "i2ctmp006_MSP_EXP430FR5969" example. Registers have been changed to BME280.
At "MSP_EXP430FR5969.c" file, pins through which we connect the sensor to MCU have been configured by the following function:
void MSP_EXP430FR5969_initI2C(void){
/*
* NOTE: TI-RTOS examples configure EUSCIB0 as either SPI or I2C. Thus,
* a conflict occurs when the I2C & SPI drivers are used simultaneously in
* an application. Modify the pin mux settings in this file and resolve the
* conflict before running your the application.
*/
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
GPIO_PIN6 | GPIO_PIN5, GPIO_SECONDARY_MODULE_FUNCTION);
I2C_init();
}
At file "i2ctmp006.cfg", at the end of the script it has been added the following:
var hwiParams = new halHwi.Params(); /* I2C Hwi for the EUSCI driver */ hwiParams.arg = 1; halHwi.create(47, "&I2CEUSCIB_hwiIntFxn", hwiParams);
At file "i2ctmp006.c" the task that is responsible for reading/writing on sensor has been programmed
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
uint8_t txBuffer[2];
uint8_t rxBuffer[2];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.transferMode = I2C_MODE_CALLBACK;
i2cParams.bitRate = I2C_400kHz;
// i2cParams.custom =
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");System_flush();
}
else {
System_printf("I2C Initialized!\n");System_flush();
}
/* Point to the T ambient register and read its 2 bytes */
txBuffer[0] = 0xE0;
txBuffer[1] = 0xB6;
i2cTransaction.slaveAddress = 0x76; //Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = NULL;
i2cTransaction.readCount = 0;
// RESET
I2C_transfer(i2c, &i2cTransaction);
Task_sleep(3000);
txBuffer[0] = 0xD0;
i2cTransaction.slaveAddress = 0x76; //Board_TMP006_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 1;
/* Take 20 samples and print them out onto the console */
for (i = 0; i < 20; i++) {
if (I2C_transfer(i2c, &i2cTransaction)) {
System_printf("Sample %u: %d - %x (C) -- ", i, rxBuffer[0], rxBuffer[0]);System_flush();
System_printf("2: - %x (C)\n", rxBuffer[1]);System_flush();
}
else {
System_printf("I2C Bus fault\n");System_flush();
}
System_flush();
Task_sleep(1000);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
}
If the following sentence
i2cParams.transferMode = I2C_MODE_BLOCKING;
is changed for
i2cParams.transferMode = I2C_MODE_CALLBACK;
it does not blocked but it does not work.
We think something is missing on proyect configuration, buy we are not sure if it is due to hardware interruption or I2C configuration.
Thanks