xCORE-200 Explorer Kit UDP (Ethernet Pins Config) Topic is solved

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
mozcelikors
Experienced Member
Posts: 75
Joined: Sat May 07, 2016 11:47 am

xCORE-200 Explorer Kit UDP (Ethernet Pins Config)

Postby mozcelikors » Fri May 20, 2016 9:55 am

Hello all,

I've been trying to figure out the UDP connection using xCORE-200 Explorer Kit. For that, I have started with the UDP example that is for the sliceKIT.
There for sliceKIT we have the ports as,

Code: Select all

port p_eth_rxclk  = on tile[1]: XS1_PORT_1J;
    port p_eth_rxd    = on tile[1]: XS1_PORT_4E;
    port p_eth_txd    = on tile[1]: XS1_PORT_4F;
    port p_eth_rxdv   = on tile[1]: XS1_PORT_1K;
    port p_eth_txen   = on tile[1]: XS1_PORT_1L;
    port p_eth_txclk  = on tile[1]: XS1_PORT_1I;
    port p_eth_int    = on tile[1]: XS1_PORT_1O;
    port p_eth_rxerr  = on tile[1]: XS1_PORT_1P;
    port p_eth_timing = on tile[1]: XS1_PORT_8C;

    clock eth_rxclk   = on tile[1]: XS1_CLKBLK_1;
    clock eth_txclk   = on tile[1]: XS1_CLKBLK_2;

    port p_smi_mdio = on tile[1]: XS1_PORT_1M;
    port p_smi_mdc  = on tile[1]: XS1_PORT_1N;
Now, I recently discovered that these ports are different in xCORE-200 Explorer, and also there are not all the ports provided. In xCORE-200 Explorer, from datasheet the pins are given as attachment (please look ).

Image

MDIO, MDC, TX_EN, and TIMING pins are not given. (Or probably related to other peripherals) Can you please help me adjust these pins for xCORE-200 Explorer RGMII? Thank you in advance . Below, you 'll find my current version, but with several ambiguities.

Code: Select all

port p_eth_rxclk  = on tile[1]: XS1_PORT_1O;
    port p_eth_rxd    = on tile[1]: XS1_PORT_8A;//4E
    port p_eth_txd    = on tile[1]: XS1_PORT_8B;
    port p_eth_rxdv   = on tile[1]: XS1_PORT_1B;
    port p_eth_txen   = on tile[1]: XS1_PORT_1L; //?
    port p_eth_txclk  = on tile[1]: XS1_PORT_1G;
    port p_eth_int    = on tile[1]: XS1_PORT_1O; //?
    port p_eth_rxerr  = on tile[1]: XS1_PORT_1A;
    port p_eth_timing = on tile[1]: XS1_PORT_8C; //?

    clock eth_rxclk   = on tile[1]: XS1_CLKBLK_1; //?
    clock eth_txclk   = on tile[1]: XS1_CLKBLK_2; //?

    port p_smi_mdio = on tile[1]: XS1_PORT_1M; //?
    port p_smi_mdc  = on tile[1]: XS1_PORT_1N; //?
You do not have the required permissions to view the files attached to this post.
View Solution
User avatar
mon2
XCore Legend
Posts: 1848
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Fri May 20, 2016 11:50 am

Have a review of this application note for details on how the Gigabit Ethernet PHY is connected to the CPU ports:

https://www.xmos.com/support/appnotes/AN00199
mozcelikors
Experienced Member
Posts: 75
Joined: Sat May 07, 2016 11:47 am

Postby mozcelikors » Fri May 20, 2016 12:59 pm

Do you know any UDP/TCP example that is related to this RGMII, because my example is for MII only. I dont know if I can use that with the RGMII configurations, I have several errors.
User avatar
mon2
XCore Legend
Posts: 1848
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Fri May 20, 2016 1:32 pm

mozcelikors
Experienced Member
Posts: 75
Joined: Sat May 07, 2016 11:47 am

Postby mozcelikors » Fri May 20, 2016 7:18 pm

Thanks, that is a very good example. That code uses many cores but I'll try later on to reduce that.
It did not work at the first try, but with a couple of adjustments to the buffer sizes, it works now. Since that person was kind enough the share his work, I must also provide the function that does exact reflection to the people who'll struggle in the future. And thanks to you too mon2.

Code: Select all

void Task_EthernetAppTCPServer(chanend c_xtcp)
{
    xtcp_connection_t conn;     // A temporary variable to hold
      // connections associated with an event
      xtcp_connection_t responding_connection;    // The connection to the remote end
      // we are responding to
      int send_flag = FALSE;  // This flag is set when the thread is in the
      // middle of sending a response packet

      // The buffers for incoming data, outgoing responses and outgoing broadcast
      // messages
      char rx_buffer[RX_BUFFER_SIZE];
      char tx_buffer[RX_BUFFER_SIZE];

      int response_len;   // The length of the response the thread is sending

      int mycount = 0;

      // Maintain track of two connections. Initially they are not initialized
      // which can be represented by setting their ID to -1
      responding_connection.id = INIT_VAL;

      // Instruct server to listen and create new connections on the incoming port
      xtcp_listen(c_xtcp, INCOMING_PORT, XTCP_PROTOCOL_TCP);
      while (1)
      {
          select
          {
              // Respond to an event from the tcp server
          case xtcp_event(c_xtcp, conn):
          switch (conn.event)
          {
          case XTCP_IFUP:
          case XTCP_IFDOWN:
              break;

          case XTCP_NEW_CONNECTION:
              // The tcp server is giving us a new connection.
              // This is a new connection to the listening port
  #ifdef DEBUG
              printstr("New connection to listening port:");
              printintln(conn.local_port);
  #endif
              if (responding_connection.id == INIT_VAL)
              {
                  responding_connection = conn;
              }
              else
              {
  #ifdef DEBUG
                  printstr("Cannot handle new connection");
  #endif
                  xtcp_close(c_xtcp, conn);
              }
              break;

          case XTCP_RECV_DATA:
              // When we get a packet in:
              //
              //  - fill the tx buffer
              //  - initiate a send on that connection
              //

              response_len = xtcp_recv_count(c_xtcp, rx_buffer, RX_BUFFER_SIZE);
              rx_buffer[response_len] = 0;
  #ifdef DEBUG
              printstr("Got data: ");
              printint(response_len);
              printstrln(" bytes");
  #endif

              for (int i = 0; i < response_len; i++)
                  tx_buffer[i] = rx_buffer[i];

  #ifdef DEBUG
              printstrln(rx_buffer);
  #endif

              //response_len = response_len + strlen(YOUSEND);
              if (!send_flag)
              {
                  xtcp_init_send(c_xtcp, conn);

                  send_flag = TRUE;
                  //mycount=10;
  #ifdef DEBUG
                  printstr("Responding: ");
                  printstrln(rx_buffer);}
  #endif
  #ifdef DEBUG
              printstrln("Cannot respond here since the send buffer is being used");
  #endif
          }
          break;

          case XTCP_REQUEST_DATA:
          case XTCP_RESEND_DATA:
          case XTCP_SENT_DATA:
              // The tcp server wants data for the reponding connection
              if (send_flag == TRUE) {
  #ifdef DEBUG
                  printstr("Resending data pf length ");
                  printintln(response_len);
  #endif
                  xtcp_send(c_xtcp, tx_buffer, response_len);
                  //xtcp_send(c_xtcp, tx_buffer, RX_BUFFER_SIZE);

              } else {
                  xtcp_complete_send(c_xtcp);
              }
              if (mycount <1) {
                  send_flag = FALSE;
              }else
              {
                  //mycount--;
              }
              break;
          case XTCP_TIMED_OUT:
          case XTCP_ABORTED:
          case XTCP_CLOSED:
  #ifdef DEBUG
              printstr("Closed connection:");
              printintln(conn.id);
  #endif
              xtcp_close(c_xtcp, conn);
              responding_connection.id = INIT_VAL;
              send_flag = FALSE;
              break;

          case XTCP_ALREADY_HANDLED:
              break;
          }
          break;
      }
  }
}

Who is online

Users browsing this forum: No registered users and 0 guests