2025-05-05 7:24 AM
Hello,
I can run older TCP/IP examples on my F767 Nucleo but I want to start fresh and understand what is going on.
Basic project started with CubeIDE/CubeMX code generation. FreeRTOS, LWIP, fixed IP => Does not answer to ping. Turns out MX_LWIP_Init() never returns.
If I step into the ethernetif initialisation code, I see that anywhere HAL_Delay(ETH_REG_WRITE_DELAY) is called within stm32f7xx_hal_eth.c, it never returns, unless I step into it from the debugger and go step by step (and see uwTickFreq increment) until HAL_Delay returns.
I understand the time base is a common issue often because of the interrupt priorities, but I think I have everything setup correctly. I am using Timer 6 as a tick source, with its IT priority set to 0.
Again, I do see uwTickFreq increment if I run the code step by step.
I removed MX_LWIP_Init() from the code and added some HAL_Delay(1000) in the for(;;) loop in the defaulttask and it returns every second, which tells me HAL_Delay() and FreeRTOS work together in the configuration I have.
I am sure I am missing something simple but I cannot tell what...
2025-05-06 12:59 AM
Hello @AndrewST
Did you try to ping without FreeRTOS?
2025-05-06 2:49 AM
@AndrewST wrote:
I am using Timer 6 as a tick source, with its IT priority set to 0.
Why set it to 0 ? (highest priority)
if FreeRTOS is used, the interrupts shouldn't be higher priority (so lower value) than FreeRTOS's configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY in FreeRTOSConfig.h:
/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
2025-05-06 2:51 AM
If you're using FreeRTOS, surely it has its own timers ... ?
2025-05-06 3:15 AM - edited 2025-05-06 3:21 AM
By default the STM32 HAL uses the Cortex M internal hardware timer SYSTICK to increment the global variable uwTick which is the tick counter used by HAL_Delay().
By default, systick is initialized in HAL_InitTick() weak function in stm32f7xx_hal.c
If you are using an RTOS (like FreeRTOS or ThreadX), the RTOS requires the Systick for its own purpose.
In that case the application should configure the HAL to use another HW timer (e.g. TIM interrupt) than Systick to increment the HAL tick.
The HW timer must be initialised correctly and the function HAL_InitTick() must be overriden (weak function) to initialize the HW TIM instead of systick.
Usually it's done in an additional source file stm32f7xx_hal_timebase_tim.c added in the application project.
example:
2025-05-07 6:52 AM
Yes. Ping works if I remove FreeRTOS.
2025-05-07 7:10 AM - edited 2025-05-07 7:18 AM
I think you have it backwards.
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY is the highest priority level that can be assigned to an ISR calling a FreeRTOS API. That's what the comment you copy/paste states.
What I described is the other way around: FreeRTOS is calling the HAL driver API functions which are using HAL_Delay which is NOT a FreeRTOS API, so it is fine.
Ironically, the code example you suggest in your second answer sets TIMER6 's ISR priority exactly to the same level, 0:
/*Configure the TIM6 IRQ priority */
HAL_NVIC_SetPriority(TIM6_DAC_IRQn, TickPriority ,0U);
2025-05-07 7:14 AM
Sorry if I am missing your point? FreeRTOS has its own timer, sure. But the HAL drivers are set to use an external timer (TIM6 here) that has a higher tick priority which should work, but it doe snot, and I am trying to figure out why.
2025-05-07 7:16 AM
Everything you are saying is done by setting "Timebase source" to TIM6, which is what I have done already.
stm32f7xx_hal_timebase_tim.c is generated automatically by CubeMX and is identical to the one in the example linked.
2025-05-07 7:28 AM - edited 2025-05-07 7:29 AM
Hellà @AndrewST
Could you please Try with ETH preemptive interrupt higher that other peripherals. Or just test the ping functionality with all other peripherals disabled.