Other Parts Discussed in Thread: TMP006
Hello,
I am trying to make my own interface with the Sensorhub TMP006 sensor, using I2C. Right now I'm only trying to write to the config address in the TMP006 module.
I followed through some of the sensorhub example program, as well as the Datasheets, and I cannot understand what is wrong and why the code is not working. Here's the line of code that gives me trouble:
I'm not sure how it's best to show how I configured the I2C3 ports, with code or with the Register maps. I'll go for both. Right before I run the highlighted line, this is how the settings for the I2C3 regs are:
The SYSCTL regs seem fine, for PortD. This is the Init function (clock is confirmed 50 MHz):
void I2C_Init(){
// Initializes I2C(3) peripheral.
// Enable clock using RCGCI2C
SYSCTL_RCGCI2C_R |= SYSCTL_RCGCI2C_R3; // 0x0000.0001
// Enable the clock to the appropriate GPIO module using RCGCGPIO
SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R3; // 0x0000.0008
// Alternate function GPIOAFSEL
GPIO_PORTD_AFSEL_R |= (GPIO_PIN_1 | GPIO_PIN_0); // pins D0 and D1
// I2CSDA pin for open-drain operation
GPIO_PORTD_ODR_R |= (GPIO_PIN_1 );
// configure appropriate pins in GPIOPCTL register
GPIO_PORTD_PCTL_R = GPIO_PCTL_PD0_I2C3SCL | GPIO_PCTL_PD1_I2C3SDA;
// Initialize I2CMCR by writing value of 0x0000.0010 (master mode)
I2C3_MCR_R |= I2C_MCR_MFE;
// Set the correct I2CMTPR register value
/*for 100kHz, we have tbit = 10000ns. If we consider
* the clock speed to be 50Mhz, then t = 20ns
* Using the formular TPR = 500/t - 1
* We get TPR = 24 = 0x18*/
I2C3_MTPR_R = 0x00000018;
}
Anyways, once I run the function, the MCS register becomes busy:
And then it gets stuck in the while loop. I am pretty sure the hardware is connected correctly, as I've run the example project with success. I cannot understand why it's staying on the busy loop, and why the write isn't happening.
EDIT: Also, the device address I'm using is 0x41, which is the same one used in the example program.
Please let me know if there is more info I can provide, and thanks in advance,
Paulo



