cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP with ethernet interrupt

user 143
Associate III
Posted on September 25, 2017 at 15:23

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. 

7 REPLIES 7
Imen.D
ST Employee
Posted on October 18, 2017 at 17:21

Hello

jurij.zapusek

,

Which device using ?

Kind Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
user 143
Associate III
Posted on October 26, 2017 at 10:35

Hallo 

Imen,

It's a STM32F107.

And I think I know my mistake. I'm calling the hole lwIP-Stack in an interrupt routine, was isn't realy nice. I think I get a stack overflow in the controller, so that the controller isn't working any more. 

nguen nguyen
Associate II

have the same issue

Piranha
Chief II

When receive interrupt is triggered, You must read all (!!!) received packets not just one.

P.S. Old ST examples and demos (for example STM3210C-EVAL demo firmware) are also working ridiculously slow and unstable most likely because of this bug.

Hallo 

 How to read all (!!!) received packets ?

low_level_input() must be called repeatedly (and packets processed) until it returns NULL.

Hi, I am using Nucleo-F767ZI, and I want to setup an interrupt to send data over ethernet every occurring interrupt. Any ideas?

Thank you!