correct SYSTICK and RELOAD_CYCLES
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "pid_control.h"
|
||||
#include "config.h"
|
||||
#include <stdint.h>
|
||||
#include <ti_msp_dl_config.h>
|
||||
|
||||
@@ -14,9 +15,9 @@ float PID_Controller(struct _PID *pid, float error) {
|
||||
float Ts = 0.0;
|
||||
uint32_t Timestamp = DL_SYSTICK_getValue(); // 假设这里是正确获取时间戳的方式
|
||||
if (Timestamp < pid->Timestamp_Last)
|
||||
Ts = (float)(pid->Timestamp_Last - Timestamp) / 9 * 1e-6;
|
||||
Ts = (float)(pid->Timestamp_Last - Timestamp) / MCLK_IN_MHZ * 1e-6;
|
||||
else
|
||||
Ts = (0xFFFFFF - Timestamp + pid->Timestamp_Last) / 9 * 1e-6;
|
||||
Ts = (0xFFFFFF - Timestamp + pid->Timestamp_Last) / MCLK_IN_MHZ * 1e-6;
|
||||
|
||||
if (Ts <= 0 || Ts > 0.05f)
|
||||
Ts = 0.001;
|
||||
|
||||
Reference in New Issue
Block a user