Hi
The I2C reads and writes fine until I use the UART_A0 and connect to server through GPRS modem on TCP. I am using the I2C to read from BME280 and send the data to the server every 10 secs. It works the first time and them gets stuct in I2C read near the line while(UCB1STAT & UCBBUSY);. If I comment this line, it get stuck at next the while(UCBICTLW0 & UCTXSTT).
unsigned int I2C_Read(unsigned int slv_addr, unsigned int reg_addr, unsigned int len, char *arr) { unsigned int i = 0; while(UCB1STAT & UCBBUSY); UCB1I2CSA = slv_addr; UCB1CTLW0 |= UCTR | UCTXSTT; while(UCB1CTLW0 & UCTXSTT); UCB1TXBUF = reg_addr; while(!(UCB1IFG & UCTXIFG0)); UCB1CTLW0 &= ~UCTR; UCB1CTLW0 |= UCTXSTT; while(UCB1CTLW0 & UCTXSTT); for(i = 0; i < len; i++) { if(i == len - 1) { UCB1CTLW0 |= UCTXSTP; } while(!(UCB1IFG & UCRXIFG0)); arr[i] = UCB1RXBUF; } while(UCB1CTLW0 & UCTXSTP); return(i); }
The same program works fine if I dont use the GPRS. Please help.
Regards
Vijay