Low Frequency PWM measuring (0 - 4Hz) and trending readings with STM32F030
I am currently using an STM32F030 MCU's external interrupt to measure an incomming PWM signals Frequency, Period, Duty Cycle and Pulse Width. The incoming signal can be between 0 - 4.167Hz. This is working great, capture all three transitions in the PWM signal, time stamp them with HAL_GetTick() and then calculate the wave's parameters using math.
Because as the signal approaches 0Hz it can take a very long time for a full signal to arrive and be characterized. For example, if the wave is 0.02Hz (which is very possible in this application) it will take 50 seconds for the full wave to arrive at the MCU before the MCU can then calculate that and tell the user the frequency. Because of this, it's been requested that I add "trending" to the code where if the last measured frequency is lets say 0.1 Hz and the user changes it to 0.02 Hz then as the MCU is waiting for the next wave to fully arrive it will slowly lower the frequency output to the user and the user can see it move down to 0.02 Hz and stop there rather than having an abrupt change 50 seconds later. Also, I would need to trend in the other direction, so if the user starts at 0.1Hz but then changes that to 0.2Hz the frequency output would slowly rise before settling at 0.2Hz 5 seconds later.
I don't know if it is possible to do this, but if it is can someone tell me how to do so? If I could just assume that it's always going down (which I can't) then I'm more confident it would be possible, but because of the need to trend both up and down I'm questioning if this is even possible.