Hot!No response from LAN9252 EtherCAT over SPI

Author
Geri
Junior Member
  • Total Posts : 93
  • Reward points : 0
  • Joined: 2005/06/30 01:06:49
  • Location: Austria
  • Status: offline
2018/07/09 05:35:27 (permalink)
0

No response from LAN9252 EtherCAT over SPI

Hello
 
I have an EtherCAT development board with LAN9252 controller, connected over SPI to a micro controller.
The board driver (XML-file for TwinCAT) is defined as SPI, 32 byte in, 32 byte out. According to TwinCAT, the board is in operational state. I am also able to switch to other states.
 
In a first step of my code, I try to execute a byte order test. So the micro controller sends the command 0x64.

for (i=0; i<10; i++) // check test register 10 times
{
  Delay_ms(20); // wait 20 mS
  TempLong.Long = SPIReadRegisterDirect (BYTE_TEST, 4); //
  if (TempLong.Long == 0x87654321) //
  break;
}
....

unsigned long SPIReadRegisterDirect (unsigned short Address, unsigned char Len)
// Address = register to read
// Len = number of bytes to read (1,2,3,4)
{
   unsigned char i;
   ULONG Result;
   UWORD Addr;
   Addr.Word = Address;

   XMC_SPI_CH_EnableSlaveSelect(XMC_SPI1_CH0, XMC_SPI_CH_SLAVE_SELECT_0);
   SPI1Transfer(COMM_SPI_READ); // SPI read command
   SPI1Transfer(Addr.Byte[1]); // address of the register
   SPI1Transfer(Addr.Byte[0]); // to read, MsByte first

   for (i=0; i<Len; i++) // read the requested number of bytes
   { // LsByte first
       Result.Byte[i] = SPI1Transfer(DUMMY_BYTE); //
   }
   XMC_SPI_CH_DisableSlaveSelect(XMC_SPI1_CH0);
   return Result.Long; // return the result
}

 
If I execute the code, I read 0xFFFFFFFF from SPI (MISO).
 
I checked the hardware -> Pinning OK
 
I did some measurements with a scope and the levels are OK:
SPI Clock is 10 kHz
/CS => OK
MOSI => OK
MISO  => always +3V3
 
If I disconnect the micro controller from the LAN9525-Eval-Board and measure the voltage level on LAN9252 on pins (13 MISO), (17 MOSI), (19 CLK)  and (50, /CS) all pins deliver +3.3V. For my opinion, the voltage level should be zero..
 
Does anyone have an idea what the problem could be?
 
Thank you and best regards
 
Geri
post edited by Geri - 2018/07/09 06:31:12

Attached Image(s)

#1

6 Replies Related Threads

    Geri
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2005/06/30 01:06:49
    • Location: Austria
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/07/10 08:47:57 (permalink)
    0
    Today I did some further analysis.
     
    I connected two EtherCAT eval boards. On board ist configurated for 8 bit digital output (direct output from LAN9252). This board works fine with TwinCAT.
     
    A second EtherCAT eval board ist configured with PIC32 EtherCAT Slave for SPI (ESI-File from Microhip).
     
    The board is detected by TwinCAT, I updated the EEPROM but the board can not be switched to OP-Mode. I am also wondering why the configuration ist not set to SPI-mode.
    (Please see picture)
     
    I think, as long as the board is not switched to SPI-Mode, it makes no sense to send and receive something from SPI..
     
    Best regards
    Geri
     
     

    Attached Image(s)

    #2
    Geri
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2005/06/30 01:06:49
    • Location: Austria
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/07/12 04:39:30 (permalink)
    0
    Problem solved
     
    Clock polarity-settings of SPI master was not correct.
     
    See also specification in DS00001909A-page 107 (year 2015) - FIGURE 10-4: SPI READ
     
    As soon as the LAN9252 is in INIT, PRE-OP or OP-State, Byte_test delivers data.
     
    Best regards
     
    Geri
    #3
    Saravanakumar_S
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/07/31 06:51:18
    • Location: 0
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/08/10 00:22:23 (permalink)
    0
    Hi Geri,
    We are facing the same problem exactly, when we are executing the sample program with TwinCAT.
    Could you please help us, How did you changed the polarity settings in SPI Master ?
    We could try the same thing.
    Thank you.
     
    Regards,
    S.Saravanakumar
    #4
    Geri
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2005/06/30 01:06:49
    • Location: Austria
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/08/14 14:20:53 (permalink)
    0
    Hello Saravanakumar
     
    In my case, the problem was not TwinCAT. It were my SPI-Settings (Clock polarity) for communication between the LAN9252 and my micro controller were wrong. I am using a XMC4500 micro controller. I currently do not have access to my source because I am on holiday.
     
    Maybe please have a look at this information source if you use PIC micro controller
     
    https://www.bausano.net/e...duino/easycat-pro.html
     
    Hope it helps and best regards
     
    Geri
    #5
    Saravanakumar_S
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/07/31 06:51:18
    • Location: 0
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/08/15 21:34:01 (permalink)
    0
    Hi Geri,
    Thank you for your reply.
    There is no problem with TwinCAT for our case also.
    As you told, we are using the PIC microcontroller <=> LAN9252. The PDI interface between PIC Microcontroller and LAN9252 will be SPI.
    In our case, LAN9252 not able to read register 0x0120 and not able to serve, the EtherCAT Master(TwinCAT) Transition request(INIT State -> PREOP State).
    Hence, It is remaining in INIT State and get into Time out error.
     
    Regards,
    S.Saravanakumar
    post edited by Saravanakumar_S - 2018/08/22 06:27:40

    Attached Image(s)

    #6
    Saravanakumar_S
    New Member
    • Total Posts : 7
    • Reward points : 0
    • Joined: 2017/07/31 06:51:18
    • Location: 0
    • Status: offline
    Re: No response from LAN9252 EtherCAT over SPI 2018/08/22 06:28:39 (permalink)
    0
    Hi Geri,
    https://www.microchip.com/DevelopmentTools/ProductDetails/evb-lan9252-hbiplus
    Example Code used: evb-lan9252-hbiplus_pic32_sdk_v1.3.zip
    EVB Lan9252 board: EVB-LAN9252-SPI
    Microcontroller:  PIC32MX795F512L
     
    We are checking the Example code as it is with PIC Microcontroller given in EVB Schematics.
    We are facing the same issue. We are not able to pass the Byte order test.
    Byte order Test return value=0x0000FF3F
    Do we need to change the SPI Polarity in order to get into PREOP Mode or OP Mode?
    Herewith, I have attached the SPI waveform for your reference.
    Kindly help us by giving debugging options. Thank you.

    Regards,
    S.Saravanakumar

    Attached Image(s)

    #7
    Jump to:
    © 2018 APG vNext Commercial Version 4.5