I am writing an application for XC-3 development board which sends and receivs data from ethernet. I managed to use the ethernet module provided by XMOS, but in my specific case I need to strip it down, since I basically only need the part that reads and sends data (bytes, words, whatever) directly to the MII. So I tried to reuse the ethernet module code. I have strange annoying issues when trying to read data though. My thread can read data from the MII, but it partially drops it. I guess I can say that around 20/30% of the words are dropped. It looks like my thread doesn't keep up with the 100Mbps ethernet speed, which is strange.
Here is a copy of the code that I am dealing with:
Code: Select all
on stdcore[2]: mii_interface_t mii =
{
XS1_CLKBLK_1,
XS1_CLKBLK_2,
PORT_ETH_RXCLK_0,
PORT_ETH_RXER_0,
PORT_ETH_RXD_0,
PORT_ETH_RXDV_0,
PORT_ETH_TXCLK_0,
PORT_ETH_TXEN_0,
PORT_ETH_TXD_0,
};
#pragma unsafe arrays
void eth_rx(in port p_mii_rxdv, in buffered port:32 p_mii_rxd)
{
unsigned rx_data[500];
int i, eof;
p_mii_rxdv when pinseq(0) :> int lo; //Wait end of current frame
while(1)
{
p_mii_rxd when pinseq(0xD) :> int sof; //Wait start of new frame
for(i=0, eof=0; eof==0; i++)
{
select
{
case p_mii_rxd :> rx_data[i]: //Read frame word
break;
case p_mii_rxdv when pinseq(0) :> int lo: //End of frame
eof=1;
break;
}
}
//After the loop I check rx_data contents...
}
}
int main()
{
par
{
on stdcore[2]:
{
phy_init(clk_smi, p_mii_resetn, smi, mii); //Function declared in ethernet module
eth_rx(mii.p_mii_rxdv, mii.p_mii_rxd);
}
}
return 0;
}
I hope someone can tell me why...what am I missing?