STM32F103 and Encoder Mode
Dear community
I develop a 'robot" with odometrie.
Each geared DC motor have a rotary magnetic encoder for speed regulation.
My question is about avoid count overload.
I use a timer for read encoder count. Each interrupt, i print the value.
My aim is avoid false data by resetting the timer count ( avoid overflow regiser)
uint16_t MSG[10]={0};
tick = (TIM4->CNT);
TIM4->CNT=1000;
sprintf(MSG,"%d\n",tick);
HAL_UART_Transmit_DMA(&huart4, MSG, strlen(MSG));
This code is inside a timer function.
Without the line "Tim4->CNT=1000", the data is correct. With it, the data seem to be strange.
>> The question, is this line is the correct way to reset the register ?