Tool/software: Code Composer Studio
Hi,
I am interfacing MAX30100(Pulse oximeter sensor) with MSP430 using I2C Communication. I am transmitting device ID address but not able to read its value. It is stucking in the received buffer. When we start I2C condition the NACKIFG is becoming always one.
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
if(Rx == 1){ // Master Recieve?
PRxData[0] = UCB0RXBUF; // Get RX data
temp++;
__bic_SR_register_on_exit(CPUOFF); // Exit LPM0
// UCB0CTL1 |= UCTXSTP; // I2C stop condition
// Rx--;
IFG2 &= ~UCB0RXIFG;
}
else{ // Master Transmit
if (TXByteCtr) // Check TX byte counter
{
UCB0TXBUF = 0xFF; // Load TX buffer address of register 0xFF
TXByteCtr--; // Decrement TX byte counter
flag--;
UCB0CTL1 |= UCTXSTP; // I2C stop condition
IFG2 &= ~UCB0TXIFG; // Clear USCI_B0 TX int flag
__delay_cycles(112505);
__bic_SR_register_on_exit(CPUOFF);
}
}
}
void init_I2C(void) {
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = itgAddress; // Slave Address is 069h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0RXIE + UCB0TXIE; //Enable RX and TX interrupt
}
void Transmit(void){
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
UCB0STAT &= ~UCNACKIFG;
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
}
void Receive(void){
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
UCB0CTL1 &= ~UCTR ; // Clear UCTR
UCB0CTL1 |= UCTXSTT; // I2C start condition
UCB0STAT &= ~UCNACKIFG;
while (UCB0CTL1 & UCTXSTT); // Start condition sent?
UCB0CTL1 |= UCTXSTP; // I2C stop condition
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
} - --------------------------->stopping here
Can anyone tell us what is the problem and how to resolve it. Thanks in advance.