Hi to all! I'm trying to develop an SPI slave. The purpose is the following: The MSP430 is a sensor module and comunicate via SPI with an ARM processor (SPI master). The MSP430 use a GPIO like an alert for ARM. In that case the ARM starts the SPI communication and the MSP430 enter into the SPI interrupt.
The code for example is the following
#include "main.h"
#include <msp430.h>
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
while(!(P9IN & BIT3)); // If clock sig from mstr stays low // it is not yet in SPI mode
P9SEL |= 0x0e; // UCLK,SOMI,SIMO=FUNC, all other=GPIOs (9.1,9.2,9.3)
/*GPIOS LED y ALERT*/
/*---------------------------------*/
P9DIR |= BIT7;
P8DIR |= BIT6; //LED
/*---------------------------------*/
UCB2CTL1 |= UCSWRST; // Put the state machine in reset
UCB2CTL0 |= UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI slave,
// Clock polarity high, MSB
UCB2CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCB2IE |= UCRXIE; // Enable USCI_B2 RX interrupt
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4, enable interrupts
for(;;)
{
volatile unsigned int i;
P8OUT ^= BIT6;
P9OUT ^= BIT7; // Toggle
i = 50000; // Delay
do (i--);
while (i != 0);
i = 50000; // Delay
do (i--);
while (i != 0);
}
}
#pragma vector = USCI_B2_VECTOR
__interrupt void USCI_B2_ISR(void)
{
switch(__even_in_range(UCB2IV,4)) // Interrupt vector register
{
case 0:break; // No interrupt
case 2: // Vector 2 - RXIFG
while (!(UCB2IFG&UCTXIFG)); // USCI_B2 TX buffer ready?
UCB2TXBUF = 0x0F;
break;
case 4: // Vector 4 - TXIFG
break;
default:
break;
}
}
---------------------------------------------------------------------------------------------
The program is blocked in the line of toggles the GPIOS. I can't find information to solve it.
If anything is wrong in my code, please tell me. Thanks!


