Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

SPI slave operation using F28335.

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hello,

I am a new-be. I am looking for an example for SPI implementation.

In my application, i need to transfer 16 bit data between an FPGA module and TMS320F28335 and at clk frequency of 100K to 1MHz.

Here, F28335 acts as a slave.

So, can any one let me know abt F28335 acting as SPI slave.

Thanks,

venkat.

  • Hello!

    I would recommend you DM (p.95) 0743.TI_TMS320f28332-35_manual.pdf.

    Regards,

    Igor

  • Hi,

    Download controlSuite from TI website. It consists of numerous examples on SPI communication.

    Regards,

    Gautam

  • Hello Igor , Gautham,

    Thanks for reply.

    I looked at manual and in Controlsuite i found loopback example.

    in loop back, if i change control register to

    SPICTL.all = 0;
    SPICTL.bit.OVERRUNINTENA = 0; // enable receiver overrun interrupts
    SPICTL.bit.CLK_PHASE = 0; // normal SPI clocking scheme (mode polarity 0 - phase 0)
    SPICTL.bit.MASTER_SLAVE = 0; // SPI configured as slave
    SPICTL.bit.TALK = 1; // enable data transmission
    SPICTL.bit.SPIINTENA = 1; // enable SPI interrupts

    and also loopback register, is it ok.

  • Hello Venkat!

    For more detailed information you can refer to this Reference Guide 3000.TI_SPI_2833x_sprueu3a.pdf.

    Regards,

    Igor

  • Hello,

    We wanna implement SPI slave in F28335. we tired to modify the example available and got something like below code.

    Can any one please let me, where are we doing mistake. 

    thanks,

    suraj.

    #include "DSP28x_Project.h" 

    interrupt void spiTxFifoIsr(void);

    void spi_xmt(Uint16 a);
    void delay_loop(void);
    void spi_fifo_init(void);
    void error();

    void main(void)
    {
        Uint16 i,j;

      InitSysCtrl();

    InitSpiaGpio();

    DINT;
    IER = 0x0000;
    IFR = 0x0000;

    InitPieCtrl();

    InitPieVectTable();

    EALLOW;

    PieVectTable.SPIRXINTA = &spiRxFifoIsr;
    PieVectTable.SPITXINTA = &spiTxFifoIsr;
    EDIS;

    spi_fifo_init();

    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;

     while(1)
     {
        i++;
        if(i%5000000 == 0)
        {


         for(j=0x40;j<0x4d;j++)
        {
         spi_xmt(j);
         }


       }

     }

     }

    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=0x001F; //16-bit character, Loopback mode
    SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
    SpiaRegs.SPICCR.bit.SPILBK = 0; // disable loopback
    SpiaRegs.SPICCR.bit.SPICHAR = 7; //8-bit character

    //SpiaRegs.SPICTL.all=0x0017; //Interrupt enabled, Master/Slave XMIT enabled
    SpiaRegs.SPICTL.bit.SPIINTENA = 1; // Interrupt disable
    SpiaRegs.SPICTL.bit.TALK = 1; // Transmit enable
    SpiaRegs.SPICTL.bit.MASTER_SLAVE = 0; //Slave
    SpiaRegs.SPICTL.bit.CLK_PHASE = 0; //Normal phase, depending on SPICCR.6 (CLOCK_POLARITY)
    SpiaRegs.SPICTL.bit.OVERRUNINTENA = 1; //Overrun interrupt disable

    SpiaRegs.SPISTS.all=0x0000;
    SpiaRegs.SPIBRR=0x0063; // Baud rate
    SpiaRegs.SPIFFTX.all=0xC028; // Enable FIFO's, set TX FIFO level to 8
    SpiaRegs.SPIFFRX.all=0x0028; // Set RX FIFO level to 8
    SpiaRegs.SPIFFCT.all=0x00;
    SpiaRegs.SPIPRI.all=0x0010;

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

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

    interrupt void spiTxFifoIsr(void)
    {
    Uint16 i;
    for(i=0;i<8;i++)
    {
    SpiaRegs.SPITXBUF=sdata[i]; // Send data
    }

    for(i=0;i<8;i++) // Increment data for next cycle
    {
    sdata[i]++;
    }


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

    void spi_xmt(Uint16 a)
    {
    Uint16 dummy;

    while(SpiaRegs.SPIFFTX.bit.TXFFST ==16);
    SpiaRegs.SPITXBUF=a;
    dummy = SpiaRegs.SPIRXBUF ;
    }

  • Hello,

    Can anyone please let me know, whether where am i doing mistake.

    Thanks,

    suraj.