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.

Minimal code for EMAC raw rx

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

Ciao,

I'm trying to setup the EMAC/MII to receive raw data from the ethernet on a Hercules TMS570LS3137 with no success.

I've post the HalCoGen prj in another message ( http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/276709.aspx ).

In CCSv5 the startup for the EMAC is done following the instruction on http://processors.wiki.ti.com/index.php/HALCoGen_Ethernet_Driver_and_lwIP_Integration_Demonstration. This is the relevant code:

As globals:

  #define PACKET_COUNT    20
  #define PACKET_SIZE    100
  #define BUFFER_SIZE    280

  typedef struct _EMAC_Desc {
    struct _EMAC_Desc *pNext;
    unsigned char     *pBuffer;
    unsigned int      BufOffLen;
    unsigned int      PktFlgLen;
  } EMAC_Desc;
 
  unsigned char rx_buff[PACKET_COUNT][BUFFER_SIZE];
  EMAC_Desc desc_buff[PACKET_COUNT];
  volatile EMAC_Desc *pDescRx[PACKET_COUNT];

In Main function (as init):

 EMACInit(EMAC_CTRL_0_BASE, EMAC_0_BASE);
MDIOInit(MDIO_0_BASE, MDIO_FREQ_INPUT, MDIO_FREQ_OUTPUT);

AutoNegotiate(MDIO_0_BASE,1,DP83640_100BTX | DP83640_100BTX_FD | DP83640_10BT | DP83640_10BT_FD);

MDIOPhyRegRead(MDIO_0_BASE, 1, PHY_LINK_PARTNER_ABLTY,&ptnerAblty);
unsigned int phyduplex = EMAC_DUPLEX_HALF;
if(ptnerAblty & DP83640_100BTX_FD) phyduplex = EMAC_DUPLEX_FULL;
EMACDuplexSet(EMAC_0_BASE, phyduplex);

EMACMACAddrSet(EMAC_0_BASE, 0, emacAddress, EMAC_MACADDR_MATCH);
 
// Clear contents of rx buffer
for(j=0; j<PACKET_COUNT; j++){
   for(k=0; k<BUFFER_SIZE; k++){
        rx_buff[j][k] = 0xFF;
    }
}
 
// Setup Rx Buffers
EMAC_Desc *pDesc = (EMAC_Desc*)desc_buff;
pDescRx[0] = pDesc;

for(j=0; j<PACKET_COUNT; j++) {
    pDesc->pNext     = pDesc + 1;
    pDesc->pBuffer   = rx_buff[j];
   pDesc->BufOffLen = sizeof(rx_buff[j]);
   pDesc->PktFlgLen = EMAC_DSC_FLAG_OWNER;
    pDesc++;
}
(pDesc-1)->pNext = 0;
 
EMACRxEnable(EMAC_0_BASE);
EMACRxHdrDescPtrWrite(EMAC_0_BASE, (unsigned int)pDescRx[0], 0);
EMACMIIEnable(EMAC_0_BASE);
EMACRxIntPulseEnable(EMAC_0_BASE, EMAC_CTRL_0_BASE, 0, 0);

in rx interrups function:
 
  int i;
  for (i=0;i<PACKET_COUNT;i++){
      EMACRxCPWrite(EMAC_0_BASE, 0, (uint32)&desc_buff[i]);
      EMACRxHdrDescPtrWrite(EMAC_0_BASE, (uint32)&desc_buff[i], 0);
  }
 
  EMACCoreIntAck(EMAC_0_BASE, EMAC_INT_CORE0_RX);


Note:
  • the Autonegotiate function is copied from your example code and returns true
  • Inside the code all non-void function are tested and there are no errors
  • the sender code is tested with your example and works
  • inside the coede there are a lot of debug messages via SCI which I have ometted here for clarity
  • I've not understand with packet descriptor should be used in the rx isr (because the function has no arguments) so the code reset all of them

The code does not works and cannot receive packets from the ethernet connection. Sometimes the rx isr is called just one time and then never more.

Can someone have a look and tell me if there's something wrong?

Thank you,

Matteo