This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2CMDR register is not getting updated in the peripheral window of the debugger

I was creating a program to communicate with the compass module(HMC5883L) using I2C module using Tiva C LaunchPad (TM4C123GH6PM. When debugging, I found that, when a write value was issued to the I2CMDR register, the value did not update in the peripheral window of the debugger. I tried with alternate I2C modules in the uC and in overall, I found that when using I2C1 module, I2C1 peripheral window in debug session, does not display any value at all for I2C1 registers. While using rest of the I2C modules, I2CMDR value in the I2C peripheral window didn't update at all(Sadly, it remained the same 0x00!). I place my source rode here. Please anyone offer suggestions. It is little urgent...!

I2C2 initialisation code

void initializeI2C( uint16_t i2cspeed, uint8_t slaveAddress)
{


SYSCTL_RCGCI2C_R |= 0X4;        //Enable I2C clock
delay = SYSCTL_RCGCI2C_R;       //create delay for clock stabilisation

SYSCTL_RCGC2_R |= 0x00000010;     // activate clock for Port  A
delay = SYSCTL_RCGC2_R;         //create delay for clock stabilisation

GPIO_PORTE_LOCK_R = 0x4C4F434B;   // unlock GPIO Port A
GPIO_PORTE_CR_R = 0xFF;           // allow changes to PF7-0

GPIO_PORTE_AFSEL_R |= (1 << 4)|(1 << 5);//Alternate function assignment to respective pins

GPIO_PORTE_ODR_R |= (1 << 5) ;            //Make I2CSDA pin for open drain configuration

GPIO_PORTE_PCTL_R |= 0x00330000;  //Set corresponding PMCx reg. for I2C2 peripheral

I2C2_MCR_R |= 0 << MFE | 0 << SFE;  //Initialise I2C as master

I2C2_MTPR_R |= ((16000/(20*i2cspeed)) - 1) << 0 | 0 << 7; //set the desired clock speed for SCL

I2C2_MSA_R = (slaveAddress << 1); //Specify the slave address for the operation

}

Here is the main code for writing to the I2CMDR register (I2C2 peripheral)

int main(void)
{

        initializeI2C3(100, 0x1E);

        I2C2_MDR_R = 0x25;

}

The code compiled without any errors and I ran through every code in the debugger, there was no problem at all, except this one.

Parents
  • Specifically, regarding the I2CMDR, you may read 0x00, as "reading" this register might return the last data returned by the addressed device. As there was no data received yet, it reads 0x00. And the data to send is no longer visible. You should check with the device manufacturer regarding the function of this register, if the device manual does not help.

Reply
  • Specifically, regarding the I2CMDR, you may read 0x00, as "reading" this register might return the last data returned by the addressed device. As there was no data received yet, it reads 0x00. And the data to send is no longer visible. You should check with the device manufacturer regarding the function of this register, if the device manual does not help.

Children
No data