For some reason I am having problems with the 5438 recognizing interrupts on the I2C ports. I know interrupts are working, I am using them for timing and USB without any problems.
Here is what I have.
I init with suggested code.
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMODE_3 + UCSYNC;// UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_1 + UCSWRST; // Use ACLK, keep SW reset
UCB0BR0 = 48; // fSCL = ACLK(1.2mHz)/48 = ~84kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x0B; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UCB0IE |= UCSTPIE + UCSTTIE + UCRXIE + UCTXIE;
Port init is:
#define SetPort3 { P3SEL = 0xB6; P3OUT = 0x00; P3DIR = 0x49; P3REN = 0x00;}
P3.4 and P3.5 are used for USB comms and works fine.
ISR code is:(again from suggested code)
#pragma vector = USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
{
switch(__even_in_range(UCB0IV,12))
{
case 0: break; // Vector 0: No interrupts
case 2: break; // Vector 2: ALIFG
case 4: break; // Vector 4: NACKIFG
case 6: break; // Vector 6: STTIFG
case 8: break; // Vector 8: STPIFG
case 10: // Vector 10: RXIFG
RXByteCtrB0--; // Decrement RX byte counter
if (RXByteCtrB0>0)
{
*PRxB0Data++ = UCB0RXBUF; // Move RX data to address PRxData
if (RXByteCtrB0 == 1) // Only one byte left?
UCB0CTL1 |= UCTXSTP; // Generate I2C stop condition
}
else
{
*PRxB0Data = UCB0RXBUF; // Move final RX data to PRxData
__bic_SR_register_on_exit(LPM0_bits); // Exit active CPU
}
break;
case 12: // Vector 12: TXIFG
if (TXByteCtrB0>0) // Check TX byte counter
{
UCB0TXBUF = *PTxB0Data++; // Load TX buffer
TXByteCtrB0--; // Decrement TX byte counter
}
else
{
UCB0CTL1 |= UCTXSTP; // I2C stop condition
UCB0IFG &= ~UCTXIFG; // Clear USCI_B0 TX int flag
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
}
default: break;
}
}
I am using a MSP-EXP5438 board talking to DeVaSys USB-I2CIO. The DeVaSys works with other applications and it does transmit when requested, but the MSP never gets an interrupt!!
Where am I going wrong?
Thanks in advance for your assistance.
GT