I am trying to communicate LTC2451 but having no luck. To troubleshoot, I tried the program below. When I run the program here is what I observe:
1) Once the UCSWRST bit gets reset, UCBBUSY comes on. It should not come on till start condition is initiated.
2) Once the UCTXSTT is set, oscilloscope shows no activity on i2c pins and UCTXSTT stays on but the uC should send out slave address and reset the UCTXSTT.
Can someone recommend what I can check, why can this be happening?
#include <msp430.h> unsigned int input; int main (void){ WDTCTL = WDTPW + WDTHOLD; P3DIR |= BIT0 + BIT1 + BIT4 + BIT5 + BIT7; __delay_cycles(3200); // Make sure ps comes on UCB0CTLW0 |= UCSWRST; //Software reset enabled UCB0IE |= UCRXIE + UCSTTIE + UCBCNTIE; __enable_interrupt(); __delay_cycles(3200); // Make sure ps comes on UCB0CTL1 |= UCTXSTT; // I2C start condition #pragma vector = USCI_B0_VECTOR static unsigned int data_pos = 1; switch(__even_in_range(UCB0IV,0x1E)) {
int z = 0;
// Init SMCLK = MCLk = ACLK = 1MHz
CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting = 8MHz
CSCTL2 = SELA_3 + SELS_3 + SELM_3; // set ACLK = MCLK = DCO
CSCTL3 = DIVA_3 + DIVS_3 + DIVM_3; // set all dividers to 1
// Configure pins
P1SEL1 |= BIT6 + BIT7;
P3OUT = BIT0 + BIT4;
UCB0CTLW0 |= UCMODE_3 + UCMST + UCSYNC; //I2C mode, Master mode, sync
UCB0CTLW1 |= UCASTP_2; //automatic stop generated
//after UCB0TBCNT is reached
UCB0BRW = 0x0008; // baudrate = SMCLK / 8
UCB0TBCNT |= 0x0002; //number of bytes to be received
UCB0I2CSA = 0x0014; //slave address
UCB0CTL1 &=~UCSWRST;
UCB0IE |= UCNACKIE; // Not Acknowledge
P1DIR |= BIT0;
while (UCB0CTL1 & UCTXSTT); // Wait while address gets sent
}
__interrupt void USCIB0_ISR(void) {
case USCI_I2C_UCNACKIFG: UCB0CTL1 |= UCTXSTT; break; // Vector 4: NACKIFG break;
case USCI_I2C_UCSTTIFG: data_pos = 1; break;
case USCI_I2C_UCRXIFG0: { *((char *)(&input) + 1 - UCBCNT0) = UCB0RXBUF; } break; // Vector 24: RXIFG0 break;
default: break;
}
}
My schematics is below.
The VCC of uC and ADC are different. Is that OK?