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.
Tool/software: Code Composer Studio
Hi
I'm using EK - TM4C1294XL with SI7021 temperature sensor and trying to get temperature but I'm getting the following error in the console. Here are the screenshots of the error also I'm attaching program below.
Program - >
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
/* Example/Board Header files */
#include "Board.h"
#define TASKSTACKSIZE 640
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
Void taskFxn(UArg arg0, UArg arg1)
{
unsigned int i;
// uint16_t Temp_Code;
// uint16_t temperature;
uint8_t txBuffer[1];
uint8_t rxBuffer[2];
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_I2C0, &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] = 0xE3;
i2cTransaction.slaveAddress = Board_SI702_ADDR;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;
/* Take 20 samples and print them out onto the console */
for(i=0 ; i<=10 ; i++)
{
if (I2C_transfer(i2c, &i2cTransaction))
{
uint16_t temp = ((rxBuffer[1]<<8) | rxBuffer[2]);
// Convert the data to readable data
float temperature = (175.72 * temp);
temperature /= 65536;
temperature -= 46.85;
System_printf("%1.2f degrees F\n", temperature);
System_flush();
}
else
{
System_printf("I2C Bus fault\n");
}
System_flush();
Task_sleep(2000);
}
/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");
System_flush();
}
/*
* ======== main ========
*/
int main(void)
{
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initI2C();
/* Construct tmp006 Task thread */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)taskFxn, &taskParams, NULL);
/* Turn on user LED */
GPIO_write(Board_LED0, Board_LED_ON);
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);
}
Hi Omkar,
Can you attach the .cfg file? Also, what version of TI-RTOS for TivaC are you using?
Todd
Hi,
Try adding the following lines to your .cfg file:
var Boot = xdc.useModule(ti.catalog.arm.cortexm4.tiva.ce.Boot)
Boot.enhancedClockMode = true;
Judah
Hi
Thank you, sir, for the reply I tried what you said and now there is no error thank you so much sir.
Best Regards,
Omkar Dixit