This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TXFFIL on SPI FIFO on Piccolo F28069

Other Parts Discussed in Thread: ADC104S021, CONTROLSUITE

 

Hello, I have an issue related to Mary West's posting of 10/6/11.  I replied to that post but as I haven't heard anything back I concluded that a new thread might be warranted.

I modified the example code to try to control a chip select by asserting it before loading the FIFO and deasserting it once the FIFO had emptied and generated a TX interrupt (I realize that the FIFO emptying means that there are still bits in the SPIDAT register that haven't been sent yet but I can pad the message to accommodate this, but I can also deassert CS early without ill effect as long as the device has gotten its first clock).

The problem I am encountering is that even when I load the FIFO up with 4 words of data I get the interrupt almost immediately even though I have TXFFIL set to 0, i.e. give me the interrupt when there are 0 words left in the FIFO (I have also tried values of 1, 2, and 3).  The system seems designed to do exactly what I want, it just doesn't happen to work.  Here's the code.  Note that I read 3 to the local variable count when I set a breakpoint at the following line.  SPIFFCT is set to 0, and the transmit interrupt is not enabled

If I replace the interrupt-enabling statement with a hard loop while ((count = SpiaRegs.SPIFFTX.bit.TXFFST) > 0); and then de-assert the line it works as expected:  the line is asserted for 3 bytes and deasserted when the last byte is loaded into the shift register bringing the TXFFST to 0.  Clearly I don't want to do the hard loop in real code though.  Why doesn't TXFFIL work as advertised regarding the interrupt, having been careful to shut off the source of interrupt and clear any pending status?

Thanks very much!

void main(void)
{
   Uint16 i;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2806x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the F2806x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example
// Setup only the GP I/O only for SPI-A functionality
   InitSpiaGpio();

// Step 3. Initialize PIE vector table:
// Disable and clear all CPU interrupts
   DINT;
   IER = 0x0000;
   IFR = 0x0000;

// Initialize PIE control registers to their default state:
// This function is found in the F2806x_PieCtrl.c file.
   InitPieCtrl();

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2806x_DefaultIsr.c.
// This function is found in F2806x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;  // This is needed to write to EALLOW protected registers
   PieVectTable.SPIRXINTA = &spiRxFifoIsr;
   PieVectTable.SPITXINTA = &spiTxFifoIsr;
   EDIS;   // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in F2806x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   spi_fifo_init();   // Initialize the SPI only

// Step 5. User specific code, enable interrupts:

// Enable interrupts required for this example
   PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
//   PieCtrlRegs.PIEIER6.bit.INTx1=1;     // Enable PIE Group 6, INT 1  RX
   PieCtrlRegs.PIEIER6.bit.INTx2=1;     // Enable PIE Group 6, INT 2  TX
   IER=0x20;                            // Enable CPU INT6
   EINT;                                // Enable Global Interrupts

 GpioDataRegs.GPADAT.bit.GPIO15 = 1; // disable nCS
 GpioDataRegs.GPADAT.bit.GPIO16 = 1; // disable nCS
 GpioDataRegs.GPADAT.bit.GPIO17 = 1; // disable nCS
   EALLOW;
   GpioCtrlRegs.GPADIR.bit.GPIO15 = 1; // SPI bus SEL0
   GpioCtrlRegs.GPADIR.bit.GPIO16 = 1; // SPI bus SEL1
   GpioCtrlRegs.GPADIR.bit.GPIO17 = 1; // SPI bus SEL2
   EDIS;

// Step 6. IDLE loop. Just sit and loop forever (optional):
    for(;;)
    {
//      SpiaRegs.SPICCR.bit.SPISWRESET = 0;

     GpioDataRegs.GPADAT.bit.GPIO15 = 0;  // assert nCS

SpiaRegs.SPIFFTX.bit.TXFFIENA = 0; // disable FIFO interrupt before loading

SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1; // Clear any interrupt that may be pending

SpiaRegs.SPITXBUF= 0xA500; // LEFT-justified 16-bit value

SpiaRegs.SPITXBUF= 0xA500; // LEFT-justified 16-bit value

SpiaRegs.SPITXBUF= 0xA500; // LEFT-justified 16-bit value

SpiaRegs.SPITXBUF= 0xA500; // LEFT-justified 16-bit value

SpiaRegs.SPIFFTX.bit.TXFFIENA = 1;

     int count = SpiaRegs.SPIFFTX.bit.TXFFST;

//     SpiaRegs.SPIFFTX.bit.TXFIFO = 1;

      SpiaRegs.SPICCR.bit.SPISWRESET = 1;
       PieCtrlRegs.PIEIER6.bit.INTx2=1;     // Enable PIE Group 6, INT 2  TX

     delay_loop();
    }

}

// Some Useful local functions
void delay_loop()
{
    long      i;
    for (i = 0; i < 1000000; i++) {}
}

void error(void)
{
    asm("     ESTOP0");  //Test failed!! Stop!
    for (;;);
}

void spi_fifo_init()
{
// Initialize SPI FIFO registers
   SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI

   SpiaRegs.SPICCR.all=0x000F;       //16-bit character, no Loopback mode


   SpiaRegs.SPICTL.all=0x0017;       //Interrupt enabled, Master/Slave XMIT enabled
   SpiaRegs.SPISTS.all=0x0000;
   SpiaRegs.SPIBRR=6;           // Baud rate divider
//   SpiaRegs.SPIFFTX.all=0xC022;      // Enable FIFO's, set TX FIFO level to 4
   SpiaRegs.SPIFFTX.all=0xC020;      // Enable FIFO's, set TX FIFO level to 4
//   SpiaRegs.SPIFFTX.all=0xC024;      // Enable FIFO's, set TX FIFO level to 4
   SpiaRegs.SPIFFCT.bit.TXDLY = 0;

   SpiaRegs.SPIFFRX.all=0x0022;      // Set RX FIFO level to 4
   SpiaRegs.SPIFFCT.all=0x00;
   SpiaRegs.SPIPRI.all=0x0010;

   SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPI

   SpiaRegs.SPIFFTX.bit.TXFIFO=1;
   SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;
}

interrupt void spiTxFifoIsr(void)
{
    // Disable SPI CLK
    PieCtrlRegs.PIEIER6.bit.INTx2=0;     // Disable PIE Group 6, INT 2  TX

    GpioDataRegs.GPADAT.bit.GPIO15 = 1;  // de-assert nCS

    SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK
}

interrupt void spiRxFifoIsr(void)
{
    rdata[0]=SpiaRegs.SPIRXBUF;     // Read data

    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
}

//===========================================================================
// No more.

  • Bruce,

    It looks like you're reading the status immediately after loading the FIFO and reading a value of 3.  What happens if you check the status in the ISR itself though?  Does it read back the FIFO interrupt level you configured?

    Are you sending to more than one SPI?  What is the reason to use the GPIO as slave select instead of the one built into the SPI?

    Kris 

  • Kris-

     Thanks for getting back to me so quickly.

    I am getting TXFFST != 0 in the ISR.

    If I check for TXFFST==0 in the interrupt handler and just set TXFFINTCLR=1 and PIEACK.all |= 0x20 if there are still characters in the buffer without deasserting then I get my expected waveform on the chip select, but I don't understand why I am getting the spurious interrupt since I cleared any pending interrupt while TXFFIENA was disabled (and again just before reeenabling TXFFIENA).

    Also, I would love to use a slave chip select mechanism in the SPI instead but didn’t see it in the Piccolo manual.  Where do I find it?  The only such thing I could find was nSPISTE for some funky audio interface:  I have a 3-wire SPI device (ADC104S021) that needs to see a chip select before the first clock, which does not appear to be what the slave-transmit-enable pin is for.  Am I missing something here?

    Thanks again,

    Bruce

  • I hooked up GPIO19 and see that nSPISTEA is acting as a chip select as desired- I was confused by the signal name.  Since I have multiple SPI devices requiring chip select I still have to use GPIO to OR together with this.  And I'm still curious about the spurious interrupt.

  • Bruce,

    Good, glad you found the STE signal.  I looked through the code and nothing jumps out to me, but I'll have access to CCS this afternoon and will try giving it a run.  I'll let you know what I find.

    I might suggest not enabling the interrupt until after you have the SPI buffer loaded for the first time.  Since you're enabling it with nothing in the buffer it may be causing an immediate interrupt.

    Kris

  • Bruce,

    This was one which was easier for me to implement than try to look through your code.  I've attached a working sample of what you're trying to do.  You will probably need to alter the number of bits sent and some small things to how you need them.

    The big obstacle here was as you predicted, the FIFO ISR being received when the last value was loaded into SPIDAT and hadn't yet been transmitted.  I came up with two possible solutions.  I implemented the easy one and figured I would let you work on the better one if you desired it :)

    The solution I use to make the slave select wait until transmission was finished was I enabled GPIO 19 (SPISTE) and intended for it not to be used.  I then enabled GPIO20 & 21 to be used as the actual STE signals going to other SPIs.  Since the STE signal is being used by the actual SPI module, we can rely on it going high when transmission is complete.  So as you'll see in my code, I hit the TX FIFO ISR, wait for GPIO19 to go high, and then set my actual slave select signals high.  This guarantees your slave device will also send data during the last transmission cycle.  The downside of this approach is a wasted IO, which is not too big of a concern for most users.

    The better approach would be to synchronize this with the RX ISR.  For each transmission you send, you know you'll be receiving data as well.  Even if no signal is coming in, the SPI will shift it whatever is on the line on the latching clock edge.  So if you set your RX FIFO level correctly, you know when you receive that interrupt you can disable your GPIO slave selects.  This saves an IO and takes less CPU bandwidth.

    As far as your code, I did look at it for a bit, but there is something wrong with the way data is being sent.  If you look at it on a scope all you will see is quick glitches on the TX line.  I'll let you compare with what I have and see if you can track it down.

    Feel free to let me know if you have any questions about why I did things a certain way.  Hope this helps.

    Kris

    //###########################################################################
    //
    // FILE:   Example_2806xSpi_FFDLB_int.c
    //
    // TITLE:  F2806x Device Spi Digital Loop Back with Interrupts Example.
    //
    // ASSUMPTIONS:
    //
    //    This program requires the F2806x header files.
    //
    //    This program uses the internal loop back test mode of the peripheral.
    //    Other then boot mode pin configuration, no other hardware configuration
    //    is required.
    //
    //    As supplied, this project is configured for "boot to SARAM"
    //    operation.  The F2806x Boot Mode table is shown below.
    //    $Boot_Table:
    //
    //    While an emulator is connected to your device, the TRSTn pin = 1,
    //    which sets the device into EMU_BOOT boot mode. In this mode, the
    //    peripheral boot modes are as follows:
    //
    //      Boot Mode:       EMU_KEY        EMU_BMODE
    //                       (0xD00)         (0xD01)
    //      ---------------------------------------
    //      Wait             !=0x55AA        X
    //      I/O              0x55AA          0x0000
    //      SCI              0x55AA          0x0001
    //      Wait             0x55AA          0x0002
    //      Get_Mode         0x55AA          0x0003
    //      SPI              0x55AA          0x0004
    //      I2C              0x55AA          0x0005
    //      OTP              0x55AA          0x0006
    //      ECANA            0x55AA          0x0007
    //      SARAM            0x55AA          0x000A   <-- "Boot to SARAM"
    //      Flash            0x55AA          0x000B
    //      Wait             0x55AA          Other
    //
    //   Write EMU_KEY to 0xD00 and EMU_BMODE to 0xD01 via the debugger
    //   according to the Boot Mode Table above. Build/Load project,
    //   Reset the device, and Run example
    //
    //   $End_Boot_Table
    //
    //
    // Description:
    //
    //    This program is a SPI-A example that uses the internal loopback of
    //    the peripheral.  Both interrupts and the SPI FIFOs are used.
    //
    //    A stream of data is sent and then compared to the received stream.
    //
    //    The sent data looks like this:
    //    0000 0001
    //    0001 0002
    //    0002 0003
    //    ....
    //    FFFE FFFF
    //    FFFF 0000
    //     etc..
    //
    //    This pattern is repeated forever.
    //
    //
    // Watch Variables:
    //     sdata[4]    - Data to send
    //     rdata[4]    - Received data
    //     rdata_point - Used to keep track of the last position in
    //                   the receive stream for error checking
    //###########################################################################
    // $TI Release: f2806x Support Library v1.15 $ 
    // $Release Date: December 12, 2011 $ 
    //###########################################################################
    
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    // Prototype statements for functions found within this file.
    interrupt void spiTxFifoIsr(void);
    interrupt void spiRxFifoIsr(void);
    void delay_loop(void);
    void spi_fifo_init(void);
    void error();
    void load_fifo(void);
    void small_delay_loop(void);
    void configure_slave_select(void);
    void enable_slave(void);
    
    Uint16 sdata[2];     // Send data buffer
    Uint16 rdata[2];     // Receive data buffer
    Uint16 rdata_point;  // Keep track of where we are
                         // in the data stream to check received data
    Uint16 slave_selected;
    
    void main(void)
    {
       Uint16 i;
    
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2806x_SysCtrl.c file.
       InitSysCtrl();
    
    // Step 2. Initalize GPIO:
    // This example function is found in the F2806x_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    // InitGpio();  // Skipped for this example
    // Setup only the GP I/O only for SPI-A functionality
       InitSpiaGpio();
       configure_slave_select();
    
    // Step 3. Initialize PIE vector table:
    // Disable and clear all CPU interrupts
       DINT;
       IER = 0x0000;
       IFR = 0x0000;
    
    // Initialize PIE control registers to their default state:
    // This function is found in the F2806x_PieCtrl.c file.
       InitPieCtrl();
    
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F2806x_DefaultIsr.c.
    // This function is found in F2806x_PieVect.c.
       InitPieVectTable();
    
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.SPIRXINTA = &spiRxFifoIsr;
       PieVectTable.SPITXINTA = &spiTxFifoIsr;
       EDIS;   // This is needed to disable write to EALLOW protected registers
    
    // Step 4. Initialize all the Device Peripherals:
    // This function is found in F2806x_InitPeripherals.c
    // InitPeripherals(); // Not required for this example
       spi_fifo_init();   // Initialize the SPI only
    
    // Step 5. User specific code, enable interrupts:
    
    // Initalize the send data buffer
       for(i=0; i<2; i++)
       {
          sdata[i] = i;
       }
       rdata_point = 0;
       slave_selected = 1;
       enable_slave();
    
       load_fifo();
    
    // Enable interrupts required for this example
       PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
       PieCtrlRegs.PIEIER6.bit.INTx1=1;     // Enable PIE Group 6, INT 1
       PieCtrlRegs.PIEIER6.bit.INTx2=1;     // Enable PIE Group 6, INT 2
       IER=0x20;                            // Enable CPU INT6
       EINT;                                // Enable Global Interrupts
    
    // Step 6. IDLE loop. Just sit and loop forever (optional):
        for(;;)
        {
        	if(slave_selected != 1) slave_selected = 1;
        	else slave_selected = 2;
        	enable_slave();
        	load_fifo();
        	small_delay_loop();
        }
    
    }
    
    // Some Useful local functions
    void delay_loop()
    {
        long      i;
        for (i = 0; i < 1000000; i++) {}
    }
    
    void small_delay_loop()
    {
        Uint16      i;
        for (i = 0; i < 10000; i++) {}
    }
    
    void error(void)
    {
    //    asm("     ESTOP0");  //Test failed!! Stop!
    //    for (;;);
    }
    
    void spi_fifo_init()
    {
    // Initialize SPI FIFO registers
       SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI
    
       SpiaRegs.SPICCR.all=0x000F;       //16-bit character
       SpiaRegs.SPICTL.all=0x0017;       //Interrupt enabled, Master/Slave XMIT enabled
       SpiaRegs.SPISTS.all=0x0000;
       SpiaRegs.SPIBRR=0x0063;           // Baud rate
       SpiaRegs.SPIFFTX.all=0xC020;      // Enable FIFO's, set TX FIFO level to 0
       SpiaRegs.SPIFFRX.all=0x0022;      // Set RX FIFO level to 4
       SpiaRegs.SPIFFCT.all=0x00;
       SpiaRegs.SPIPRI.all=0x0000;
    
       SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPI
    
       SpiaRegs.SPIFFTX.bit.TXFIFO=1;
       SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;
    }
    
    interrupt void spiTxFifoIsr(void)
    {
    	// Disable both transmit enables.  Just as efficient as checking which is enabled
    	while(!GpioDataRegs.GPADAT.bit.GPIO19);
    	GpioDataRegs.GPASET.bit.GPIO20 = 1;
    	GpioDataRegs.GPASET.bit.GPIO21 = 1;
    
    	SpiaRegs.SPIFFTX.bit.TXFFIENA = 0;
        SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK
    }
    
    interrupt void spiRxFifoIsr(void)
    {
        Uint16 i;
        for(i=0;i<4;i++)
        {
            rdata[i]=SpiaRegs.SPIRXBUF;     // Read data
        }
    
        rdata_point++;
        SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
        SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
    }
    
    void load_fifo(void)
    {
        Uint16 i;
        for(i=0;i<4;i++)
        {
           SpiaRegs.SPITXBUF=sdata[i];      // Send data
        }
    
        for(i=0;i<4;i++)                    // Increment data for next cycle
        {
           sdata[i]++;
        }
        SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;
        SpiaRegs.SPIFFTX.bit.TXFFIENA = 1;
    }
    
    void configure_slave_select(void)
    {
    	Uint16 i;
    	EALLOW;
    
    	// Configure GPIO19 & GPIO20 to be manual slave selects
    	GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 0;
    	GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 0;
    	GpioCtrlRegs.GPADIR.bit.GPIO20 = 1;
    	GpioCtrlRegs.GPADIR.bit.GPIO21 = 1;
    
    	// Do a small delay loop after configuring IOs
    	for(i=0; i<10; i++) asm(" NOP");
    
    	// Set both GPIOs high to begin
    	GpioDataRegs.GPASET.bit.GPIO20 = 1;
    	GpioDataRegs.GPASET.bit.GPIO21 = 1;
    
    	EDIS;
    }
    
    void enable_slave()
    {
    	if(slave_selected == 1)
    	{
    		// Enable slave 1 to transmit
    		GpioDataRegs.GPACLEAR.bit.GPIO20 = 1;
    	}else GpioDataRegs.GPACLEAR.bit.GPIO21 = 1;
    }
    //===========================================================================
    // No more.
    //===========================================================================
    
    
    
    

  • Hi Kris,

    I was reading yours and Bruce's code, and 2 lines were confusing me...

    1. when you configure the FFRX register:

    SpiaRegs.SPIFFRX.all=0x0022; // Set RX FIFO level to 4

    isn't the level set to 2 ?

    2. in the interrupt, the PIEACK line:

    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK

    should be without the "or" - | , as it'll clear all other flags...

    i'm trying to set up now a communication between a master and a slave and have some difficulties...

    but here's 2 small questions:
    1. should the clocks (phase and polarity) be configured the same on the master and the slave ? what's the preffed configuration for such a setup (by the way, i'm using a low baud rate, 500Kb/sec)
    2. which interrupts would you suggest using on the master and on the slave (i thought using the RX would be better, since then i know all the data is ready inside the fifo...)

    thanks
    Ari
  • Ari,

    Good catches! This was just a quick modification of one our controlSUITE examples to show the the use of an IO as a STE line, so please don't take this code to be perfect by any means.  

    To answer your questions:

    1) You want to have the phase and polarity the same on the master and the slave.  Pay close attention to the waveform diagrams though if the slave device is from a different manufacturer.  PHASE/POLARITY = 0 may not correspond on one device to the PHASE/POLARITY = 0 on the next device.

    2) Your post is a little cut off here, but I'll try to answer what I think you're asking.  I assume you're using multiple slaves since you're responding to this thread and this question is in regards to which ISR to use to return the IO (SPISTE) high.  The best solution would be to use the RX interrupt as you indicated.  This is a bit trickier, but it reduces the CPU overhead.  If your application isn't too concerned about CPU overhead, then the example I presented should work fine.  Make sure your TX and RX FIFOs are set to the same level.  There may be some other "gotchas" that I'm not thinking of, but I expect it to be fairly simple implementation.

    Kris

  • Kris,

    I have a question regarding the sample code attached on  the post you replied on Mrach 13. That is, how to determine the data got from SpiaRegs.SPIRXBUF sending from which SPI slave device?  Under normal working condition the data shoud be alternatively received from both devices. But in case of unexpected  issue with one of the 2 SPI slave devices(e.g hardware connection issue), do we have any way to figure out which device is not in normal condition?

     

    harvey

  • Harvey,

    Since you have to manually toggle your GPIO to be a slave select line for each external device, you can just check the GPxDAT register to see which slave is currently selected and is not correctly sending data.

    Kris

  • If possible, I could use some assistance troubleshooting. I have the F28027 C2000 LaunchPad and a L3GD20 gyroscope. I am trying to write to the gyroscope over SPI to set its configuration and read the data off of it. I've been able to set up a logic analyzer and I can see that I'm definitely sending out data, but I'm just getting FF FF FF over and over again in the MISO line.

    I altered the TI SPI FIFO with interrupts project to what I think is the correct configuration of SPI. I am TX'ing the configuration settings in the TX ISR:

    interrupt void spiTxFifoIsr(void)
    {
    if (configcount == 0){
    SpiaRegs.SPITXBUF = 0x20EC; //CTRL_REG1 - output data rate, bandwidth, power mode, axes enable
    SpiaRegs.SPITXBUF = 0x220A; //CTRL_REG3 - data ready int, fifo overrun int
    configcount++;
    }
    else if (configcount ==1){
    SpiaRegs.SPITXBUF = 0x2310; //CTRL_REG4 - full scale selection
    SpiaRegs.SPITXBUF = 0x2440; //CTRL_REG5 - enable FIFO
    configcount++;
    }
    else if (configcount == 2){
    SpiaRegs.SPITXBUF = 0x2E40; //FIFO_CTRL - FIFO mode == stream
    SpiaRegs.SPITXBUF = 0xA000;
    configcount = 0;
    }

    SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1; // Clear Interrupt flag

    PieCtrlRegs.PIEACK.all|=0x20; // Issue PIE ACK
    }

    The 0xA000 TX is intended to send the read command to the gyroscope to read back the CTRL_REG1 register.


    The RX ISR is as follows:

    interrupt void spiRxFifoIsr(void)
    {

    Uint16 i;
    for(i=0;i<3;i++)
    {
    rdata[i]=SpiaRegs.SPIRXBUF; // Read data
    }

    rdata_point++;
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR=1; // Clear Overflow flag
    SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20; // Issue PIE ack
    }


    I have configured the SPI as such:

    void spi_init()
    {
    // Initialize SPI FIFO registers
    SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SPI

    SpiaRegs.SPICCR.all=0x004F; //16-bit character
    SpiaRegs.SPICTL.all=0x0007; //Interrupt enabled, Master/Slave XMIT enabled
    SpiaRegs.SPISTS.all=0x0000;
    SpiaRegs.SPIBRR=0x006F; // Baud rate
    SpiaRegs.SPIFFTX.all=0xC022; // Enable FIFO's, set TX FIFO level to 2
    SpiaRegs.SPIFFRX.all=0x0022; // Set RX FIFO level to 2
    SpiaRegs.SPIFFCT.all=0x00;
    SpiaRegs.SPIPRI.all=0x0010;

    SpiaRegs.SPICCR.bit.SPISWRESET=1; // Enable SPI

    SpiaRegs.SPIFFTX.bit.TXFIFO=1;
    SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;

    configcount = 0; //reset the configuration counter
    }