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); } }