AnsweredAssumed Answered

LwIP with ethernet interrupt

Question asked by user 143 on Sep 25, 2017
Latest reply on Oct 26, 2017 by user 143

Hey guys,

for speed optimization I want to use ethernet interrupt when a new packet recieves. For this, first I changed heth.Init.RxMode to ETH_RXINTERRUPT_MODE and after that I added the interrupt handler with:

void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
{ }

This works so far fine. For example I can toggle a LED in the interrupt handler. 

Now I removed the ethernetif_input(&gnetif); call from the main while loop and put it into the interrupt handler. 

Well, this isn't working really fine. I recieve a few packets, but then the interrupt isn't calling anymore. 

So I searched for my mistake and had an idea. What happens when a packet is in the stack and a interrupt is calling? 

Now I changed the interrupt handler to this:

void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
{

NVIC_DisableIRQ(ETH_IRQn);
ethernetif_input(&gnetif);
NVIC_EnableIRQ(ETH_IRQn);
}

 

Now it's working better, but after round 20 recieved packets it took about 5 seconds between sending a packet from the pc to the call of the interrupt. And with every received packet it's getting more worse, until I receive no more packets. 

 

Where is my mistake? 

 

Thank you. 

Outcomes