2022-09-06 03:35 AM
I want to connect my MCU with a module which has a specific way of communication. Module sends messages of variable number of characters, where period between two characters is also variable. My idea is to use timer in order to overcome this problem. Let's assume that module sends 5 characters. After reception of the first character, timer will be activated. Assuming that the second character is sent shortly after the first, after it's reception timer will be reset and started again. Principe is the same for the rest 3 characters. As there is no more data to receive, timer will reach it's predefined, experimentally defined value and generate interrupt, therefore notify MCU about one full message reception.
In a nutshell, timer will be reset after reception of each character.
I want to configure TIM7 in normal mode on STM32G070. My main problem is how to reset timer. There are several ways I came across the internet:
Reading MCU's reference manual doesn't gave me any idea how to reset timer. As mentioned above, is there a way to reset the timer?
2022-09-06 04:33 AM
Just simply write zero value to TIM7->CNT register...
BTW: if you are receiving on UART, consider using UART "timeout" feature.