From 0d58029f71ccefc299864aa2a7c09fe9a8362ced Mon Sep 17 00:00:00 2001 From: 1923777848 <1923777848@qq.com> Date: Tue, 12 Aug 2025 14:34:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=B3=E8=BD=AC=E6=97=B6?= =?UTF-8?q?=E5=A4=9A=E6=AE=B5=E6=B3=A2=E5=BD=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TrainCamp_zhangcheng_PLSR/app/src/plsr.c | 28 ++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/TrainCamp_zhangcheng_PLSR/app/src/plsr.c b/TrainCamp_zhangcheng_PLSR/app/src/plsr.c index ad8409c..52a36c4 100644 --- a/TrainCamp_zhangcheng_PLSR/app/src/plsr.c +++ b/TrainCamp_zhangcheng_PLSR/app/src/plsr.c @@ -161,11 +161,11 @@ void PlsrModuleTask(void *pArg) continue; } - if (plsr.segment[currentSegment].pulseFreq <= 5000) - pulseFreq = 3360 - 1; - else if ((plsr.segment[currentSegment].pulseFreq > 5000) + if (plsr.segment[currentSegment].pulseFreq <= 1000) + pulseFreq = 2625 - 1; + else if ((plsr.segment[currentSegment].pulseFreq > 1000) && (plsr.segment[currentSegment].pulseFreq <= 100000)) - pulseFreq = 2 - 1; + pulseFreq = 4 - 1; else continue; @@ -435,23 +435,19 @@ static void FirstSegmentProc(SEGMENT_PART *segmentPart) incAll += segmentPart->inc; if (plsr.segment[currentSegment].pulseFreq <= 5000) { - tim10.setPsc(&tim10, 3360 - 1); - if (currentSpeed != 0) - tim10.setPer(&tim10, 50000 / currentSpeed); - else - tim10.setPer(&tim10, 1000); - tim10.registerIrq(&tim10, TimCallBack, ¤tSeg.currentPart); - tim10.open(&tim10); - tim10.openIrq(&tim10); + tim10.setPsc(&tim10, 2625 - 1); } else { tim10.setPsc(&tim10, 168 - 1); - tim10.setPer(&tim10, 1000000 / currentSpeed); - tim10.registerIrq(&tim10, TimCallBack, ¤tSeg.currentPart); - tim10.open(&tim10); - tim10.openIrq(&tim10); } + if (currentSpeed != 0) + tim10.setPer(&tim10, 168000000 / (TIM10->PSC + 1) / currentSpeed); + else + tim10.setPer(&tim10, 1000); + tim10.registerIrq(&tim10, TimCallBack, ¤tSeg.currentPart); + tim10.open(&tim10); + tim10.openIrq(&tim10); } }