Other Parts Discussed in Thread: , MSP-FET
Hi,
I am using RF430FRL152H as I2C master with a single slave device (MAX5395). I'm encountering issues where the I2C write will get stuck infinitely waiting on an interrupt flag to be set in UCB0IFG, only after flipping VDDSW (either by physically disconnecting VDDB from VDDSW, or by exposing the device to an RF field and causing a change in BS_VR_VBN).
My I2C initialization code:
// Set pins to I2C (see datasheet p.33-34)
// SDA
P1DIR |= BIT0;
P1SEL0 |= BIT0;
P1SEL1 &= ~BIT0;
// SCL
P1DIR |= BIT1;
P1SEL0 |= BIT1;
P1SEL1 &= ~BIT1;
// Initialize USCI
UCB0CTL1 |= UCSWRST; // Software reset enabled
UCB0CTLW0 |= UCMODE_3 + UCMST + UCSYNC + UCTR; // I2C mode, Master mode, sync, transmitter
UCB0CTLW0 |= UCSSEL_2; // select SMCLK at 2MHz
UCB0CTLW1 |= UCASTP_1 + UCGLIT_0; // Automatic STOP generation, deglitch time
UCB0BRW = 40; // 2Mhz / 40 = 50kHz
UCB0CTL1 &= ~UCSWRST; // exit reset mode
My I2C write code:
UCB0CTL1 |= UCSWRST; // Software reset enabled
UCB0I2CSA = MAX5395_I2C_ADDR; // I2C slave address
UCB0CTLW1 = UCASTP_1;
UCB0TBCNT = 0x0002;
UCB0CTL1 &= ~UCSWRST; // put eUSCI out of reset
UCB0CTL1 |= UCTXSTT + UCTR; // start i2c write operation
while(!(UCB0IFG & UCTXIFG0)); // send the I2C address
UCB0TXBUF = command; // send the command
while(!(UCB0IFG & UCTXIFG0)); // wait until the command is sent out
UCB0TXBUF = txData; // send the LSB
while(!(UCB0IFG & UCBCNTIFG)); // wait until it has been transmitted
UCB0CTL1 |= UCTXSTP; // send the stop condition
while(!(UCB0IFG & UCSTPIFG)); // wait until it has been received
UCB0CTL1 |= UCSWRST; // put the eUSCI into reset mode
My main loop is set to repeatedly run both the initialization & write code in a loop. It works, until I flip VDDSW, after which it always stalls after writing the I2C address, as shown in the logic analyzer capture below. But I know that that the device retains power, because other functionality works (e.g. the program keeps executing if I disable the I2C code... a PWM output on a different pin still works... etc).
Please let me know any suggestions to resolve.
Thanks,
Jason