fix timer hickup

This commit is contained in:
sdes1
2025-11-10 14:31:35 +01:00
parent 1ee6bcc841
commit 039fafd2c4

View File

@@ -33,9 +33,10 @@ extern int16_t pidValue;
void timer_Task(void *pdata) {
if(pidValue){
uint16_t interval = 64;//(64000/abs(pidValue));
uint16_t interval = (64000/abs(pidValue));
uint8_t direction = pidValue<0;
//UCOS_Printf("%d %d\r\n", direction, interval);
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
timer_Stop(1);
timer_Set_Interval_Length(1,interval);
timer_Start(1);
@@ -106,6 +107,8 @@ static void timer_Stop(uint32_t Id){
/* * * sets new interval length and the correct matchvalue * * */
static void timer_Set_Interval_Length(uint32_t Id, uint16_t interval_length){
if(XTtcPs_GetCounterValue(&xttcps) >= interval_length)
XTtcPs_ResetCounterValue(&xttcps);
XTtcPs_SetMatchValue(&xttcps, 0, interval_length/2);
XTtcPs_SetInterval(&xttcps, interval_length);
}