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.

CCS/TMS320F28335: TMS320F28335 interface with Wiznet W5500

Part Number: TMS320F28335

Tool/software: Code Composer Studio

hello,

I am trying to interface 28335 with wiz-net W5500 , but am having some problems while trying to establish the connection.

below shown is the frame format i need to send

For the testing purpose there is a read back register in w5500 which should read back the value 0x04 if the connection is perfect. But unfortunately am getting the wrong values every time. 
The source code for the same is as shown below

InitSpiaGpio()
{
EALLOW;


GpioCtrlRegs.GPBPUD.bit.GPIO54 = 0; //Enable pull-up on GPIO54 (SPISIMOA)
GpioCtrlRegs.GPBPUD.bit.GPIO55 = 0; //Enable pull-up on GPIO55 (SPISOMIA)
GpioCtrlRegs.GPBPUD.bit.GPIO56 = 0; //Enable pull-up on GPIO56 (SPICLKA)
GpioCtrlRegs.GPBPUD.bit.GPIO57 = 1; //Enable pull-up on GPIO57 (SPISTEA)

GpioCtrlRegs.GPBQSEL2.bit.GPIO55 = 3; // Asynch input GPIO17 (SPISOMIA)
GpioCtrlRegs.GPBQSEL2.bit.GPIO56 = 3; // Asynch input GPIO18 (SPICLKA)
GpioCtrlRegs.GPBQSEL2.bit.GPIO57 = 3; // Asynch input GPIO19 (SPISTEA)

GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 1; // Configure GPIO54 as SPISIMOA
GpioCtrlRegs.GPBMUX2.bit.GPIO55 = 1; // Configure GPIO55 as SPISOMIA
GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 1; // Configure GPIO56 as SPICLKA
GpioCtrlRegs.GPBMUX2.bit.GPIO57 = 1; // Configure GPIO57 as SPISTEA
GpioDataRegs.GPBSET.bit.GPIO57 = 1; // set SPISTEA idle high


// Gpio pin configures as reset pin
GpioCtrlRegs.GPBPUD.bit.GPIO63 = 1; // enable pull up
GpioCtrlRegs.GPBQSEL2.bit.GPIO63 = 3;
GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1; //

GpioDataRegs.GPBCLEAR.bit.GPIO63 = 1;
Uint16 tmp = 0xFF;
while(tmp--);
GpioDataRegs.GPBSET.bit.GPIO63 = 1;

}

void spi_init()
{
SpiaRegs.SPICCR.all =0x0047; // Reset on, falling edge, 8-bit char bits
SpiaRegs.SPICTL.all =0x00E; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x001F;
SpiaRegs.SPICCR.all =0x00C7; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
}

void_ReadVersionReg()
{

GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; //STE Low
sdata = 0x0039;
spi_xmit(sdata);

sdata = sdata>>8;
spi_xmit(sdata);

sdata = 0x0000;
spi_xmit(sdata);

sdata =sdata>>8;
spi_xmit(sdata);

GpioDataRegs.GPBSET.bit.GPIO57=1;  //STEA High

rdata = 0x00;
rdata = SpiaRegs.SPIRXBUF;

}

  • Sooraj,

    W5500 1 byte data read format is:

    16 bit Address phase: 0x0039 (As you are trying to access Chip version register)

    8 bit control phase:           0x00 (Reading in VDM mode) (or) 0x0001 (Reading command register (1 byte) in FDM mode

    8-bit data phase:               0x00 (Dummy transmit to receive 1 byte from W5500.

    1) To start with, if you are configuring GPIO57 as SPISTEA, you don't need to manually set and clear GPIO57, SPI hardware will automatically control it. If you wish to control it manually, you need to configure GPIO57 as GPIO output pin.

    2) Did you try probing SPI bus with SPI protocol analyzer? How did the SPI frame look like? Did it match with what W5500's SPI frame format

    3) Check for SPISTS.INT_FLAG before reading SPIRXBUF register. This confirms that SPI has received complete character specified.

    Regards,

    Manoj

  • Is this issue resolved?

  • Sir,

    Thanks for the help..

    Yes i changed the GPIO57 Configuration to GPIO output .
    I probed the spi Bus and the signals seems to as per requirement. Here is the screenshot if the MOSI line and Clock.

    Yellow is the spi clock and green is the MOSI line.

    And i changed the data transmitting code like this ...can you please confirm the code is doing what required,?

    Uint8 spi_data[4]={0,};
    Uint8 i;
    spi_data[0] = 0x00;
    spi_data[1] = 0x39;
    spi_data[2] = 0x00;
    spi_data[3] = 0x00;
    GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; //cs low
    for (i=0;i<4;i++)
    {
    SpiaRegs.SPITXBUF = (spi_data[i]<<8);
    }
    rdata =SpiaRegs.SPIRXBUF>>8;

     GpioDataRegs.GPBSET.bit.GPIO57 = 1;


  • also reading the SpiaRegs.SPISTS.bit.INT_FLAG is giving me 0.. is this means my data is to not being send properly?

  • I didn't see any glaring mistake in your code snippet. But, your oscilloscope snapshot shows lot of noise on both SPICLK and MOSI signals. EMI noise observed is possibly caused by ringing noise because of improper impedance matching. The concern here is the noise in high enough to incorrectly read wrong bit messing up your communication.

    Regards,

    Manoj

  • Manoj,

    Thanks Sir for the support and help. 

    I was able to solve the issue. I think the problem was with the SPI mode and the STEA signal. I was able to correct it.

  • Can you please explain more description on what was the problem and how you solved it?

    Regards,

    Manoj