2023-11-04 12:42 PM
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 ?
2023-11-06 5:06 AM
Hello @jlecl.1,
Thank you for your question.
Here are some remark :
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.