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.

TMS320F28035: 28035 SPI mode 0

Part Number: TMS320F28035


Hi all,

I'm having trouble figuring out the SPI for the 28035. I am trying to talk to a flash chip using master mode 0 but the signals output by the 28035 do not seem correct for mode 0. Below is a picture of what I see when I output 0x90 (channel 1 is clock and channel 2 is MOSI). For mode 0 I expect MOSI to be sampled on the rising clock edge but instead it is being sampled on the falling clock edge. Therefore the flash chip does not properly receive the 0x90 command.

Just for reference, this timing diagram is what I expect to see when setting up the 28035 for master mode 0 and outputting 0x90 (channel 2 being MOSI). I obtained this trace by putting the 28035 in mode 1, but then of course the flash chip won't return the correct data because it's expecting mode 0.

Here is my SPI initialization code:

SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1;

/* disable the SPI-A interrupt */

SpiaRegs.SPICTL.bit.SPIINTENA = SPI_INT_DISABLE;

/* enable internal pull-ups on the SPI-A pins */

GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0;

GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0;

GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0;

// GpioCtrlRegs.GPAQSEL1.bit.GPIO3 = 3;

// GpioCtrlRegs.GPAQSEL1.bit.GPIO5 = 3;

GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3;

/* configure pins to provide SPI-A functionality */

GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 2;

GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 2;

GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1;

/* use mode 0 */

SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;

SpiaRegs.SPICTL.bit.CLK_PHASE = 0;

/* enable transmit functionality */

SpiaRegs.SPICTL.bit.TALK = 1;

/* set 8 bit transfers and master mode */

SpiaRegs.SPICCR.bit.SPICHAR = SPI_CHAR_8_BITS;

SpiaRegs.SPICTL.bit.MASTER_SLAVE = SPI_MASTER;

/* use LSPCLK for the SPI-A frequency */

SpiaRegs.SPIBRR = 0;

/* release SPI A from reset */

SpiaRegs.SPICCR.bit.SPISWRESET = SPI_SW_RESET_RELEASE;

 

 

I've used SPI extensively but am totally stuck on this one. I would appreciate any help!!!!  Thanks in advance!

  • Doug,

    All the SPI signals needs to use ASYNC option as SPI peripheral by itself performs synchronization. Performing additional synchronization may cause unexpected results as you have seen.

    Make sure to select ASYNC option as shown below. This should resolve your issue.
    GpioCtrlRegs.GPAQSEL1.bit.GPIO3 = 3;
    GpioCtrlRegs.GPAQSEL1.bit.GPIO5 = 3;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3;

    Regards,
    Manoj
  • Hi Manoj,

    Thank you for the prompt reply, however, setting all SPI pins to asynch mode still did not cure the problem. SPI mode 0 still transmits as seen in the first scope trace I included in the original request for help.

    Could you please advise further?

    Thank you for your help!
  • Doug,

    The C2000 Device does not necessarily align with other "MODEs" as defined for other devices. The Phase and Polarity bits mean different things. Please refer to the user guides to determine what your transmit and receive edges are, and compare them with your Flash chip. Do not just match PHASE = 0 and Polarity = 0 and assume the MODE is the same. Refer to Figure 3 and Table 4 in http://www.ti.com/lit/sprug71 for the descriptions of each setting.

    Thanks,
    Mark
  • Doug,

    I noticed that you rejected my proposed solution, but have not provided feedback as to what you tried and what the result is.
    Please post any followup questions, or the additional debug steps/results so that we may assist you further.

    -Mark
  • Hi Mark,

    Thank you for the followup. Setting CPOL to 0 and CPHA to 1 did produce the correct signals for SPI mode 0. That threw me because this is the first processor where I have seen that, however, SPI is now working.

    Thank you for your help and have a great day!

    Regards,

    Doug