1

I'm trying to create a simple EtherCat slave. The hardware I use is the EVB-LAN9252 and a NUCLEO-G491RE board. As Slave Stack I use SOES. The EtherCat SDK (slave editor) from rt-labs is used to generate the ESI file, a bin file for the EEPROM and some c files. With the slave explorer from the EtherCat SDK the slave can then be tested.

very much the same as in this project

After I built the project and started the Master (EtherCat Explorer), the slave could enter op-mode. But I couldn't read the Object Dictionary. I checked SPI and it isn't doing what I'm expecting it to do.

To check if SPI is working properly I tried to read out the BYTE_TEST register (0x64), which returns the value 0x431400 instead of 0x87654321. To read the register I used the following code (modified function from SOES to run on Cube IDE):

uint32_t lan9252_read_32 (uint32_t address)
{
   uint8_t data[7];
   uint8_t result[7];
       memset(data, 0, sizeof(data));

    data[0] = ESC_CMD_READ;  //0x03
    data[1] = ((address >> 8) & 0xFF);
    data[2] = (address & 0xFF);

    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, RESET);
    HAL_SPI_TransmitReceive(&hspi1, data, result, sizeof(data), HAL_MAX_DELAY);
    HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, SET);

   return((result[6] << 24) |
          (result[5] << 16) |
          (result[4] << 8)  |
          result[3]);

}

oscilloscope image

My SPI settings (STM32 operates as ful duplex master):

  • Data Size: 8 Bits

  • First Bit: MSB First

  • Baud Rate: 1.328125 MBits/s

  • Clock Polarity: HIGH

  • Clock Phase: 2 Edge (I tried all combinations of Clock Polarity and Clock Phase so i don't think the problem is there)

The EtherCAT Slave Controller Configuration Area of the EEPROM has the value 80 0F 00 CC 88 13 FF 00 00 00 00 80 00 00 57 00. The first Byte is the initialization value for the PDI Control register (0x140 -0x141). 0x80 sets the the Process Data Interface to SPI, so the problem can't be there either.

Gmari
  • 11
  • 2
  • I'm sure you have already, but check that the 4 jumpers on the EVB-LAN9252 are set to connect the SPI signals to the connector. (Or wire your SPI pins directly onto the correct jumper pins.) – pmacfarlane Jan 27 '23 at 22:31
  • Thank You for your reply. I checked the connections and they should be fine (SPI wires directly connected to pin 2 without any jumpers). Also because I'm getting a response (just the wrong one), I think that the Problem lays either in the code I uploaded on the STM32 or in the files generated by the EtherCat slave editor. – Gmari Jan 31 '23 at 08:12
  • @Gmari the EEPROM values that you show are the standard / pre-loaded values for the EVB-LAN9252 board. Were you able to resolve this issue? – Jeffrey Stewart Jun 16 '23 at 14:57

0 Answers0