Hi,
I am working on I2C communication with the msp430 and the LSM9DS1 chip. I am using the ez430-cc2500 evaluation board. I am using the msp430 in master receive mode, trying to receive the data from the LSM chip. The problem I am having is my interrupt is never called when data should be coming in, meaning no data is coming in. My code walks through the steps needed for I2C and seems to receive all slave acknowledgements from the LSM, but it gets trapped in never receiving the data. The LSM has a specific operation for I2C as outlined in my code below. It operates find through the last SAK, but then never receives data which is the next operation.
#include <msp430.h>
unsigned char RXData;
unsigned char RXCompare;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3DIR |= 0x0F; // disable cc2500
P3SEL |= 0x06; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC + UCA10 + UCSLA10; // I2C Master, synchronous mode, 10 bit mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0xD4; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0RXIE; // Enable RX interrupt
RXCompare = 0; // Used to check incoming data
while (1)
{
/*1) start
2) slave address + W
3) slave ack
4) slave subaddress
5) slave ack
6) start repeat
7) slave address + R
8) slave ack
9) data
10)NMAK
11)stop
*/
UCB0CTL1 |= UCTXSTT + UCTR; // 1) I2C start condition
UCB0I2CSA = 0xD4; // 2) Send Slave address + W
while (UCB0CTL1 & UCTXSTT); // 3) Start condition sent?
UCB0I2CSA = 0x35; // 4) Send slave sub-address
while (UCB0CTL1 & UCTXSTT); // 5) Slave ack?
UCB0CTL1 |= UCTXSTT + UCTR; // 6) start repeat (restart)
UCB0I2CSA = 0xD5; // 7) Send Slave address + R
while (UCB0CTL1 & UCTXSTT); // 8) Slave ack?
//UCB0CTL1 |= UCTXSTP; // I2C stop condition
// while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
}
}
// USCI_B0 Data ISR
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0TX_VECTOR))) USCIAB0TX_ISR (void)
#else
#error Compiler not supported!
#endif
{
RXData = UCB0RXBUF; // Get RX data
__bic_SR_register_on_exit(CPUOFF); // Exit LPM0
}
Any thoughts as to what the problem could be? Thanks!