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 4 wire mode Operation using TMS320F28027

Other Parts Discussed in Thread: TMS320F28027, CC2520

Hi,

I am working with TMS320F28027 piccolo. I want to operate in  SPI 4 wire mode to communicate with a tranceiver chip.I am using this tranceiver to receive a signal from transmitter side.Currently i am seeing on scope that the signal is received properly by the tranceiver but it is not getting communicated properly to SPI.

Earlier i was running in loopback mode(SpiaRegs.SPICCR.bit.SPILBK=1;) and my receiver was receiving signals properly from transmitter side(i checked the received digital signal on scope by directly probing on the receiver) but it was not read properly by TMS320F28027(I checked the value of received signal in watch window and it was wrong).Then,I figured out that i am reading the same value on watch window what i send.This is how i figured out that i was operating in loopback mode but then i changed the configuration to disable the loopback mode (SpiaRegs.SPICCR.bit.SPILBK=0;) and now the receiver has stopped receiving any signals.

Please advice me for operating SPI in 4 wire mode as there are no examples in control suite which demonstrate this.

Here is my code for SPI AND SPI-FIFO Initialization

{
SpiaRegs.SPICCR.bit.SPISWRESET=0;
SpiaRegs.SPICCR.bit.CLKPOLARITY=0;
SpiaRegs.SPICCR.bit.SPICHAR=7;

SpiaRegs.SPICTL.all =0x000E; // Enable master mode, SPICLK delayed by half cycle

// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x0000;
SpiaRegs.SPICCR.bit.SPILBK=0;
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
SpiaRegs.SPIPRI.bit.TRIWIRE= 0;
SpiaRegs.SPICCR.bit.SPISWRESET=1;
}
void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x2044;//0x2044
SpiaRegs.SPIFFCT.all=0x0;

}

Thanks

Misha

  • Misha,

    Here's some very basic working code that I've been working with recently where the MCU is the master and transmits/receives correctly (note that the GPIO setup and SPI clock enable is not shown).  It's not necessarily optimized code at the moment, but hopefully it will guide you to your issue.

    See attached.


    Thank you,
    Brett

  • Hi brett,

    Thanks for your quick reply.I tested your code but still was not able to receive signals from receiver.Also,i found out some bug in the code that you sent me.

    In SPI_Rx() you have for(i=0;SpiaRegs.SPIFFRX.bit.RXFFST;i++).Shouldnt second statement be a conditional statement when you write for(initialization;conditional test;increment) statement? Also, parenthesis were missing after 'for' statement.I corrected these two but still couldnt run.

    I would be grateful if you can also send the part of the code where you call SPI_Tx and SPI_Rx in main interrupt service routine as i believe i am having problem there.Can you think of anything else that might be causing this problem?In my case specially,when i enable Loopback mode,my receiver starts receiving signals correctly but when i disable it,SPICLK goes to zero and no signal is received.

    Thanks for your help and cooperation!

    Misha

  • Misha,

    I don't really wish to parse everything out of my project (it is much more complicated).  Really you should be able to call SPI_TX() and the C2000 will transmit and should be able to call SPI_RX() whenever you expect that you've received data.  If SpiaRegs.SPIFFRX.bit.RXFFST from the SPI_RX function never becomes greater than 0 then I would recommend checking your connections and hardware (as well as confirming GPIO configuration again).

    Misha Kumar said:

    In SPI_Rx() you have for(i=0;SpiaRegs.SPIFFRX.bit.RXFFST;i++).Shouldnt second statement be a conditional statement when you write for(initialization;conditional test;increment) statement? Also, parenthesis were missing after 'for' statement.I corrected these two but still couldnt run.



    The second statement is still a condition.  It evaluates to FALSE when RXFFST is 0 and evaluates to TRUE otherwise.  {} braces are not required after a for loop or if statement.  If the brackets are omitted the compiler assumes that only the next line goes with the for statement, if statement, etc.  These are style things though, changing them should not affect much.


    Thank you,
    Brett


  • Dear Brett,

    Thank you for your reply.I could run my code finally.Thank you for your support.The problem was the way i was testing my circuit.

    I would be grateful if you can answer one more question.I am currently using a 2.4 GHz RF Tranceiver from Nordic Semiconductor.It is very slow (requires at least 200 microsecond between two consecutive transmissions).I am looking for something at least 5-6 times faster for my application(I need to transmit/receive data every 30-40 microsecond).Can you suggest some device preferably from TI which can serve this purpose?

    Thanks

    Misha

  • Misha,

    A parametric search of many of TI's wireless connectivity solutions can be found below:
    http://www.ti.com/paramsearch/docs/parametricsearch.tsp?family=wireless&familyId=1624&sectionId=646&tabId=2736&uiTemplateId=WLS_PRDSRCH_T

    Unfortunately, I don't have as much knowledge in this area.  I've seen the CC2520 (particularly the CC2520-EMK) used in some C2000 applications.  Without digging into datasheets, I'm unsure about the transmission speed of this device though.

    Perhaps some other forum readers will have more ideas.


    Thank you,
    Brett