Hi Hugh, I did not find any specific documentation on the way sys_now() should be implemented. After debugging I noticed that sys_check_timeouts was using following macro:
/* Check if timer's expiry time is greater than time and care about u32_t wraparounds */ #define TIME_LESS_THAN(t, compare_to) ( (((u32_t)((t)-(compare_to))) > LWIP_MAX_TIMEOUT) ? 1 : 0 ) So I suspect that the timer should run all the way to the unsigned 32 bit wraparound point. This is only hit after 49 days so I didn't dig deeper as my application doesn't run that long. The problem was that the ms function for my microcontroller was wrapping around after 71583 so instead of hitting 71584 it would start at zero again. Below is my quick and dirty fix for this which might contain future bugs, is gcc specific and also specific to the 71583 wrap around point. Feedback always appreciated. u32_t sys_now( void ) { static uint32_t ms = 0; static uint32_t lastMs = 0; uint32_t newMs = cpu_cy_2_ms( Get_sys_count(), sysclk_get_cpu_hz() ); uint32_t diffMs; if( newMs < lastMs ) { diffMs = ( newMs + 4294895712 ) - ( lastMs + 4294895712 ); diffMs -= 4294895712; } else { diffMs = newMs - lastMs; } lastMs = newMs; ms += diffMs; return ms; } -- Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users