cancel
Showing results for 
Search instead for 
Did you mean: 

Using Ethernet in interrupt mode with Cube generated code on STM32H7 (LwIP + HAL + baremetal)

simon_t153
Associate

I have a project which is using the STM32H723 to communicate with host PC over ethernet (UDP/IP). Currently I am working with a nucleo development board. I followed the tutorials on the forum and example repos on github to get things working.

I have very strict timing requirements and I am not using an RTOS. I have been benchmarking different parts of my code and have noticed that on occasion the UDP server that I have running takes much longer to send out a response (handful of ms instead of a fraction of a ms). I narrowed down the blocking code to the `HAL_ETH_Transmit();`  call from `low_level_output` in the etherntif.c file generated by Cube.

Reading through the HAL documentation I found that there exists a `HAL_ETH_Transmit_IT()` function which should send out packets without blocking. I enabled the ethernet interrupt in Cube code generation tool and then had to edit both the `low_level_output` and `ethernet_link_check_state` functions in ethernetif.c to use the interrupt variety of HAL_ETH and I had to register the `HAL_ETH_TxCpltCallback` to call `HAL_ETH_ReleaseTxPacket` to get things to work.

 

My question is as follows: Is there a reason that the generated Cube code does not use the HAL ethernet functions in interrupt mode? Am I missing something with what I have done or is this modification the "right" way to do it? Are there settings in Cube that I could have used to generate the correct code from the get go?

1 REPLY 1
ASEHST
ST Employee

Hello,

Your approach is entirely correct. Using interrupts for Ethernet transmission helps improve performance and reduce response times. While CubeMX offers customization options, it does not always cover all advanced use cases by default.

To ensure that Ethernet interrupts are properly configured, check in CubeMX that the interrupts are enabled in the NVIC section. After generating the code, it is often necessary to customize certain parts to meet specific requirements. This includes adding interrupt handlers and configuring interrupt priorities.

 

With Regards,

If your question is answered, please close this topic by clicking "Accept as Solution".