Hello!
I am using a DS3231 module with TM4C123GXL. It works perfectly on its own. In particular, I use pins PD0, PD1 with SCL3.
However, I also use EB-LM4F120-L35 LCD touch screen. According to the user manual, PD0 & PD1 has no connection, so I assume these two devices are compatible. However they are not. I try to debug and found out that pin B6 & B7 is interfering the process. Specifically, the problem shows as below;
read_time_from_RTC(); //works perfectly and returns good value.
GPIOPinTypeGPIOOutput(0x40005000, GPIO_PIN_6); //pin B6
read_time_from_RTC(); //can get through but returns bad value;
GPIOPinTypeGPIOOutput(0x40005000, GPIO_PIN_7); //pin B7
read_time_from_RTC(); //get stuck and won't return value.
The code stuck after "flag 5" and entering the loop: while(I2CMasterBusy(I2C3_MASTER_BASE)) {} //this line
detailed code is shown below. I2CMasterBusy() is also given for a direct reference.
void I2C_byte(unsigned char slave_address, unsigned char data) {
volatile int i = 0;
// start I2C transmit
I2CMasterSlaveAddrSet(I2C3_MASTER_BASE, slave_address, false);
I2CMasterDataPut(I2C3_MASTER_BASE, data);
UARTprintf("flag 3 ");
while(I2CMasterBusy(I2C3_MASTER_BASE)) {}
UARTprintf("flag 4 ");
// Single Byte
I2CMasterControl(I2C3_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);
UARTprintf("flag 5 ");
while(I2CMasterBusy(I2C3_MASTER_BASE)) {} //this line
UARTprintf("Success! \n");
}
tBoolean
I2CMasterBusy(unsigned long ulBase)
{
//
// Check the arguments.
//
ASSERT(I2CMasterBaseValid(ulBase));
//
// Return the busy status.
//
if(HWREG(ulBase + I2C_O_MCS) & I2C_MCS_BUSY)
{
return(true);
}
else
{
return(false);
}
}
Could anyone tell why this happens? Thank you very much!