hello,
I am trying to get the I2c going on a tm4c1237hpz using my own board. If I run the board without debugging then the I2c functions as expected. If I debug it just hangs waiting on a busy flag that never sets.
I have been checking the latency on the busy flag being set (logger[] array). I seen this in another post. Am i doing anything wrong or non-standard?
SYSCTL->RCGCI2C = SYSCTL_RCGCI2C_R1; // Enable I2C run mode clock
I2C1->MCR = I2C_MCR_MFE; // Enable I2C master mode
I2C1->MTPR = ((uiCoreClockSpeed / (20 * uiFrequency)) - 1); // 100KHz transfer rate
I2C1->MSA = I2C_WRITE_ADDRESS; // IO expander I2C address
I2C1->MDR = I2C_CONFIG_PORT0; // TX register to write
I2C1->MCS = (I2C_MCS_START | I2C_MCS_RUN); // TX start, address + register
logger[0] = I2C1->MCS;
logger[1] = I2C1->MCS;
logger[2] = I2C1->MCS;
while(!(I2C1->MCS & I2C_MCS_BUSY));
while(I2C1->MCS & I2C_MCS_BUSY); // Wait for TX complete
I2C1->MDR = 0x07; // TX Port 0 setting -> All P0.0 to P0.2 as inputs
I2C1->MCS = I2C_MCS_RUN; // TX data only
logger[3] = I2C1->MCS;
logger[4] = I2C1->MCS;
logger[5] = I2C1->MCS;
while(!(I2C1->MCS & I2C_MCS_BUSY)); <----------------------------------------------------- hangs here
while(I2C1->MCS & I2C_MCS_BUSY); // Wait for TX complete
I2C1->MDR = 0x00; // TX Port 1 setting -> All outputs
I2C1->MCS = (I2C_MCS_RUN | I2C_MCS_STOP); // TX data + stop
logger[6] = I2C1->MCS;
logger[7] = I2C1->MCS;
logger[8] = I2C1->MCS;
while(!(I2C1->MCS & I2C_MCS_BUSBSY));
while(I2C1->MCS & I2C_MCS_BUSBSY); // Wait for TX complete
I2C1->MSA = I2C_WRITE_ADDRESS;
I2C1->MDR = I2C_OUTPUT_PORT1;
I2C1->MCS = (I2C_MCS_START | I2C_MCS_RUN); // TX start, address + register
logger[9] = I2C1->MCS;
logger[10] = I2C1->MCS;
logger[11] = I2C1->MCS;
while(!(I2C1->MCS & I2C_MCS_BUSY));
while(I2C1->MCS & I2C_MCS_BUSY); // Wait for TX complete
I2C1->MDR = 0x00; // Port 1 outputs = 0
I2C1->MCS = (I2C_MCS_RUN | I2C_MCS_STOP); // TX data + stop
logger[12] = I2C1->MCS;
logger[13] = I2C1->MCS;
logger[14] = I2C1->MCS;
while(!(I2C1->MCS & I2C_MCS_BUSY));
while(I2C1->MCS & I2C_MCS_BUSY);
while(I2C1->MCS & I2C_MCS_BUSBSY);
I appreciate any help. I am really stuck on this one. Even just a nudge in the right direction would be great.
Thanks
sarah