Dear mates,
I`m using a STM32F103C8T6 (bluepill board) for two input capture (frequency meter), for 4 to 600Hz, square wave from a VR sensor.
I chained TIM3 as master to TIM2 as slave, used ST AN2592 as guide
https://www.st.com/resource/en/application_note/cd00165509.pdfThe frequency is being fed to CH1 and CH2 of both timers, so I`m feeding the signal in two IO pins per channel.
Used STM32CubeMX for configs, and Atollic as IDE.
TIM3 and TIM2 is configured this way:
Basically, whenever I have a input capture interruption, I read tim2 channel and tim3 channel (wherever channel 1 or 2, depends on the interrupt) as two 16 bit and assemble them as 32 bit. Doing that twice I get the frequency period and the frequency is them 10MHz(APB1 Timer clock)/frequency period.
It works like a charm for capturing two channels but, every 5s or so a glitch happen in the capture (both channels). The glitch is the delta capture (second capture minus the first) is around 65536. So, the TIM2 (slave) sometimes is counting one unit plus and others one unit less.
Attached, a small sample from STM Studio (the signal is capture delta).
Am I missing any thing to correctly chain this timers?
Greetings!