I am working with MSP430F55xx as slave and MSP43056xx as a master. I want to receive 1 kB data from the slave repeatedly. In the master, I have a timer which interrupts the CPU every 500 ms to write 1 byte command to the slave, otherwise master always requests 1 kB data from the slave. I am able to recieve 1 kB data for the first time , but then as observed in the oscilloscope, the master does not acknowledge to the slave anymore. As soon as the timer is on, I2C communication stops. Any suggestion on what is wrong with the protocol? Snipet of the master code is given below.
int main(void)
{
timer_init();
I2C_init ();
while(1)
{
__bis_SR_register( GIE); // Enter LPM0, enable interrupts
if ((timer_flag==1)
{
timer_flag=0;
while (UCB1CTL1 & UCTXSTP); // Ensure no stop condition
UCB1I2CSA = 0x00; // Broadcast
UCB1CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
UCB1TXBUF = 0x55; // Load TX buffer
for (i=0;i<10;i++);
UCB1CTL1 |= UCTXSTP; // I2C stop condition
UCB1IFG &= ~UCTXIFG; // Clear USCI_B0 TX int flag
for (i=0;i<10;i++);
}
receive_bytes
{ __bic_SR_register( GIE); // Disbale All int.
RXByteCtr=1024;
UCB1I2CSA = 0x47; // Slave's address
UCB1IE |= UCRXIE+ UCNACKIE;
UCB1CTL1 &= ~ UCTR ;
while (UCB1CTL1 & UCTXSTP);
UCB1IE |= UCRXIE+ UCNACKIE;
__bis_SR_register( GIE);
UCB1CTL1 |= UCTXSTT;
for (i=0;i<10;i++);
}
}
//------------------------------------------------------------------------------
#pragma vector = USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
switch(__even_in_range(UCB1IV,12))
{
case 0: break; // Vector 0: No interrupts
case 2: break; // Vector 2: ALIFG
case 4:
UCB1CTL1 |= UCTXSTP;
break; // Vector 4: NACKIFG
case 6: break; // Vector 6: STTIFG
case 8: break; // Vector 8: STPIFG
case 10: // CCN Recieves DATA
RXData = UCB1RXBUF;
break;
}
}
#pragma vector=TIMERB0_VECTOR
__interrupt void TIMERB0_ISR (void)
{
timer_flag=1;
}