fix timer hickup
This commit is contained in:
@@ -33,9 +33,10 @@ extern int16_t pidValue;
|
|||||||
|
|
||||||
void timer_Task(void *pdata) {
|
void timer_Task(void *pdata) {
|
||||||
if(pidValue){
|
if(pidValue){
|
||||||
uint16_t interval = 64;//(64000/abs(pidValue));
|
uint16_t interval = (64000/abs(pidValue));
|
||||||
uint8_t direction = pidValue<0;
|
uint8_t direction = pidValue<0;
|
||||||
//UCOS_Printf("%d %d\r\n", direction, interval);
|
//UCOS_Printf("%d %d\r\n", direction, interval);
|
||||||
|
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
|
||||||
timer_Stop(1);
|
timer_Stop(1);
|
||||||
timer_Set_Interval_Length(1,interval);
|
timer_Set_Interval_Length(1,interval);
|
||||||
timer_Start(1);
|
timer_Start(1);
|
||||||
@@ -106,6 +107,8 @@ static void timer_Stop(uint32_t Id){
|
|||||||
|
|
||||||
/* * * sets new interval length and the correct matchvalue * * */
|
/* * * sets new interval length and the correct matchvalue * * */
|
||||||
static void timer_Set_Interval_Length(uint32_t Id, uint16_t interval_length){
|
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_SetMatchValue(&xttcps, 0, interval_length/2);
|
||||||
XTtcPs_SetInterval(&xttcps, interval_length);
|
XTtcPs_SetInterval(&xttcps, interval_length);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user