Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Discussion Groups

Discussion Groups | MSP430 | I2C Problems

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

I2C Problems - Ashley - Aug 7 18:33:39 2008


I have an OMAP3 chip hooked to a MSP430 (F2272) via the I2C. The OMAP
is the master and the MSP is the slave in my configuration. The
problem that I am having is the MSP never records the first data byte
transferred. I am able to receive and transmit, but the data that I
receive is never the data that is sent.

Has anyone else encountered this problem before??

Below is my code. Any help is appreciated

-Ashley-

void initialize_i2c(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
//P3SEL |= 0x06; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMODE_3 + UCSYNC; // I2C Slave, synchronous mode
UCB0I2COA = 0x30; // Own Address is 030h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB0I2CIE |= UCSTPIE + UCSTTIE; // Enable STT and STP interrupt
IE2 |= UCB0TXIE; // Enable TX interrupt
}

void slave_test()
{
PRxData = (unsigned char *) RxBuffer;
PTxData = (unsigned char *) RxBuffer;//TxData;
TXByteCtr = 0;
RXByteCtr = 0;
while (1)
{
if (RXByteCtr > 1)
{
int x;
for (x = 0 ; x < RXByteCtr; x++)
{
if (RxBuffer[x] != x)
{
//Data not received correctly
dummy = 1; //put break point here
break;
}
}
RXByteCtr = 0;
zeroizeBuffer();
PRxData = (unsigned char *) RxBuffer;
}
if (TXByteCtr)
{
PTxData = (unsigned char *) RxBuffer; //TxData;
TXByteCtr = 0;

}
}
}

//------------------------------------------------------------------------------
// The USCI_B0 data ISR is used to move data from MSP430 memory to the
// I2C master. PTxData points to the next byte to be transmitted, and
TXByteCtr
// keeps track of the number of bytes transmitted.
//------------------------------------------------------------------------------
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_isr(void)
{
int x ;
for (x = RXByteCtr; x > 0; x--)
{
UCB0TXBUF = *PTxData++; // Transmit data at address PTxData
TXByteCtr++; // Increment TX byte counter
}
}

//------------------------------------------------------------------------------
// The USCI_B0 state ISR is used to wake up the CPU from LPM0 in order
to do
// processing in the main program after data has been transmitted. LPM0 is
// only exit in case of a (re-)start or stop condition when actual data
// was transmitted.
//------------------------------------------------------------------------------
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_isr(void)
{
*PRxData++ = UCB0RXBUF; // Read data transmitted
RXByteCtr++;
UCB0STAT &= ~(UCSTPIFG + UCSTTIFG); // Clear interrupt flags
}
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )