We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I'm using LPC1788 with KSZ8051 PHY and some strange things are happening.
Most part of the time the communication works ok, but sometimes a packet written to EMAC is not transmitted.
At least 1 packet in 100 is lost and have to be retransmitted.
Does anyone have a clue about it?
My source code for transmitting :
void WriteData_EMAC(void *Source, unsigned int Size) { unsigned int idx; unsigned short * piSource; unsigned short *txptr;
__set_PRIMASK(1);
idx = LPC_EMAC->TxProduceIndex; txptr = (unsigned short *)TX_DESC_PACKET(idx);
TX_DESC_CTRL(idx) = Size | TCTRL_LAST | TCTRL_INT;
piSource = Source; Size = (Size + 1) & 0xFFFE; // round Size up to next even number
while (Size > 0) { *txptr++ = *piSource++; Size -= 2; }
if (++idx == NUM_TX_FRAG) idx = 0;
while( idx == LPC_EMAC->TxConsumeIndex );
LPC_EMAC->TxProduceIndex = idx;
__set_PRIMASK(0);
}
Thankyou!