I am using M430F2618T as a slave and Cyclone II fpga as a master in SPI data transfer. just for the purpose of testing, I want to transfer a square wave (MOSI signal) to microcontroller and get the same signal back as (MISO signal) at fpga. Here is the code for a microcontroller. Though I am able to get MOSI signal at microcontroller, I am not able to get MISO signal back at the fpga. Please suggest ay changes to be made in the microcontroller code.
#include <msp430x26x.h>
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
// // it is not yet in SPI mode
P3SEL |= 0x31; // P3.5,4,0 option select
UCA0CTL1 = UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCSYNC+UCMSB; //3-pin, 8-bit SPI slave
UCA0CTL0 &= ~UCMST;
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
while (1)
{
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF;
}
}