Bladeren bron

2025.09.01

master
Chiri 4 weken geleden
bovenliggende
commit
8393ec8d5a
15 gewijzigde bestanden met toevoegingen van 2137 en 2160 verwijderingen
  1. +32
    -25
      Core/Src/main.c
  2. +2
    -4
      Core/Src/stm32f4xx_it.c
  3. +7
    -11
      Core/Src/tim.c
  4. +704
    -704
      EWARM/PLSR.dep
  5. +1320
    -1321
      EWARM/PLSR.ewp
  6. +3
    -3
      EWARM/settings/PLSR.dbgdt
  7. +10
    -7
      EWARM/settings/PLSR.dnx
  8. +16
    -16
      EWARM/settings/Project.wsdt
  9. +4
    -36
      EWARM/settings/Project_EditorBookmarks.xml
  10. +22
    -24
      Hardware/PLSR.c
  11. +1
    -0
      Hardware/PLSR.h
  12. +1
    -6
      Hardware/PSCARR.c
  13. +15
    -3
      PLSR.ioc
  14. BIN
      Words/测试大纲.doc
  15. BIN
      Words/设计方案书 .doc

+ 32
- 25
Core/Src/main.c Bestand weergeven

@@ -46,7 +46,7 @@ uint32_t N_Acc = 0;

uint8_t EXT_Flag = 0;
uint8_t PulseStartFlag = 0;
uint8_t ArrTimes = 0;
uint32_t ArrTimes = 0;
uint8_t FixArrFlag = 0;
uint8_t PulseRuning = 0;

@@ -83,7 +83,7 @@ void SystemClock_Config(void);
#define TASK_Y1Direction 6
#define TASK_PulseStart 5
#define TASK_DirOutput 6
#define TASK_PulseGetCount 4
#define TASK_PulseGetCount 5
#define TASK_EXTSet 6

/* 任务堆栈大小 */
@@ -248,7 +248,6 @@ int main(void)
NowFrequency = PulseOutput[Options.StartPulse].Frequency;
NowPulse = Options.StartPulse;
N_Acc = PulseOutput[Options.StartPulse].Frequency * Options.AccDownTime / 2000;
CPU_CRITICAL_EXIT() ; ///退出临界区

@@ -457,9 +456,9 @@ void PulseGetCount(void *p_arg)
if (TIM2->CNT != 0) CNT_Only[NowPulse] = TIM2->CNT;
AllPulseCNT = CNT_Only[0] + CNT_Only[1] + CNT_Only[2] + CNT_Only[3] +
CNT_Only[4] + CNT_Only[5] + CNT_Only[6] + CNT_Only[7] +
CNT_Only[8] + CNT_Only[9] + CNT_Only[10];
CNT_Only[8] + CNT_Only[9];
CountSave();
OSTimeDly(10, OS_OPT_TIME_DLY, &err);
}
}
@@ -541,15 +540,16 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
if (htim == (&htim3))
{
/* 段切换的加减速 */
if (ArrFlag == 1 && NowPulse != 10)
if (ArrFlag == 1)
{
/* 脉冲加速 */
if (PulseOutput[NowPulse].Frequency > PulseOutput[PrePulse].Frequency) /* 如果当前的脉冲频率大于之前的脉冲频率 */
{
if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccUp)
{
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccUp);
ArrTimes++;
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccUp);
}
else
{
@@ -579,7 +579,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
/* 实时修改频率的加减速 */
if (FixArrFlag == 1 && NowPulse != 10)
if (FixArrFlag == 1)
{
/* 脉冲加速 */
if (PulseOutput[NowPulse].Frequency > NowFrequency)
@@ -587,12 +587,12 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
if (ArrTimes <= Options.AccUpTime)
{
SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccUp);
// if(ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */
ArrTimes++;
}
else
{
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency);
NowFrequency = PulseOutput[NowPulse].Frequency;
ArrTimes = 0;
FixArrFlag = 0;
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
@@ -610,32 +610,37 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
else
{
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency);
NowFrequency = PulseOutput[NowPulse].Frequency;
ArrTimes = 0;
FixArrFlag = 0;
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
}
}
}
/* 第一段脉冲的加速 */
if (NowPulse == Options.StartPulse && PulseStartFlag == 1)
{
if (ArrTimes <= PulseOutput[Options.StartPulse].Frequency / AccUp)
{
ArrTimes++;
SetFrequency(Options.SentPost, ArrTimes * AccUp);
if (ArrTimes == 1) PulseStart(); /* 开始产生脉冲 */
}
else
{
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency);
PulseStartFlag = 0;
ArrTimes = 0;
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
}
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency);
PulseStart();
PulseStartFlag = 0;
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
// if (ArrTimes <= PulseOutput[Options.StartPulse].Frequency / AccUp)
// {
// ArrTimes++;
// SetFrequency(Options.SentPost, ArrTimes * AccUp);
// if (ArrTimes == 1) PulseStart(); /* 开始产生脉冲 */
//
// }
// else
// {
// SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency);
// PulseStartFlag = 0;
// ArrTimes = 0;
// HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
// }
}
#ifdef Acc
/* 最后一段脉冲的减速 */
if (PulseRuning == 0 && NowPulse == 10)
{
@@ -653,6 +658,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断
}
}
#endif
}
OSIntExit(); /* 退出中断 */


+ 2
- 4
Core/Src/stm32f4xx_it.c Bestand weergeven

@@ -238,7 +238,6 @@ void TIM2_IRQHandler(void)
NowPulse = PulseOutput[NowPulse].NextPulse - 1; /* 进入下一段脉冲 */
}
ArrFlag = 1;
N_Acc = PulseOutput[NowPulse].Frequency * Options.AccDownTime / 2000;
SetNextPulse();/* 设置下一次进入中断的脉冲数 */
NowFrequency = PulseOutput[NowPulse].Frequency; /* 保存当前脉冲的频率 */
@@ -251,9 +250,8 @@ void TIM2_IRQHandler(void)
PulseCount = 0;
ArrFlag = 0;
PulseRuning = 0;
PrePulse = NowPulse; /* 保存之前的脉冲段 */
NowPulse = 10;
HAL_TIM_Base_Start_IT(&htim3); /* 启动定时器3和中断 */
PulseEnd();
//HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */
}
}


+ 7
- 11
Core/Src/tim.c Bestand weergeven

@@ -151,11 +151,7 @@ void MX_TIM10_Init(void)
Error_Handler();
}
/* USER CODE BEGIN TIM10_Init 2 */
__HAL_TIM_CLEAR_FLAG(&htim10, TIM_FLAG_UPDATE);
__HAL_TIM_CLEAR_IT(&htim10, TIM_IT_UPDATE);
TIM10->SR = 0; // Ö±½ÓÇå³ý״̬¼Ä´æÆ÷

/* USER CODE END TIM10_Init 2 */
HAL_TIM_MspPostInit(&htim10);

@@ -178,7 +174,7 @@ void MX_TIM11_Init(void)
htim11.Init.CounterMode = TIM_COUNTERMODE_UP;
htim11.Init.Period = 1;
htim11.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim11.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
htim11.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim11) != HAL_OK)
{
Error_Handler();
@@ -189,7 +185,7 @@ void MX_TIM11_Init(void)
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim11, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
@@ -219,7 +215,7 @@ void MX_TIM13_Init(void)
htim13.Init.CounterMode = TIM_COUNTERMODE_UP;
htim13.Init.Period = 1;
htim13.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim13) != HAL_OK)
{
Error_Handler();
@@ -230,7 +226,7 @@ void MX_TIM13_Init(void)
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim13, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
@@ -260,7 +256,7 @@ void MX_TIM14_Init(void)
htim14.Init.CounterMode = TIM_COUNTERMODE_UP;
htim14.Init.Period = 1;
htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim14) != HAL_OK)
{
Error_Handler();
@@ -271,7 +267,7 @@ void MX_TIM14_Init(void)
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim14, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{


+ 704
- 704
EWARM/PLSR.dep
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 1320
- 1321
EWARM/PLSR.ewp
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 3
- 3
EWARM/settings/PLSR.dbgdt Bestand weergeven

@@ -153,7 +153,7 @@
<RecentlyUsedMenus>1</RecentlyUsedMenus>
<MenuShadows>1</MenuShadows>
<ShowAllMenusAfterDelay>1</ShowAllMenusAfterDelay>
<CommandsUsage>7812000025001386000005000000298100001F00000010860000830600002CE100000200000029E1000004000000239200000600000020810000060000000F810000010000005F860000040000001D810000010000000C8100001000000004860000030000005986000001000000288100002500000056860000110300002BE100000700000000840000030000001F810000190100000E81000002000000098600000100000025E10000010000000B8100000600000000E10000020000001486000081020000588600000200000027810000120000000086000002000000058100000100000011860000840300000281000001000000468100002C01000060860000010000001E810000060000005D86000017000000088600000500000005860000010000001686000001000000</CommandsUsage>
<CommandsUsage>0B1500002800298100002200000013860000060000002CE10000060000001086000064070000239200000600000029E10000040000005F860000040000000F81000001000000208100000600000001E10000010000000C810000100000001D81000001000000598600000100000004860000030000005686000026030000288100003900000000840000030000002BE100000800000028E100000C00000025E100000100000009860000010000000E810000020000001F8100003801000000E10000020000000B81000006000000588600000200000014860000EB0200001186000031040000058100000100000000860000020000002781000020000000468100004A0100000281000001000000218100000A000000608600000100000008860000050000005D8600001E0000001E8100000600000016860000010000000586000001000000</CommandsUsage>
</MFCToolBarParameters>
<CommandManager>
<CommandsWithoutImages>300020870000238700002487000021870000198600000D8400000F84000008840000FFFFFFFF54840000328100001C810000098400002AE10000008200001C8200000182000067860000838600005886000004DC00007784000007840000808C000044D500007486000045D5000046D5000047D5000048D5000049D500004AD500004BD500004CD500001C8F00001E8F00001F8F0000208F0000218F0000118F000000DC000001DC000002DC000003DC0000A4860000A38600005486000059860000</CommandsWithoutImages>
@@ -1013,7 +1013,7 @@
<item>AccDown</item>
<item>ArrTimes</item>
<item>temp</item>
<item />
<item></item>
</expressions>
<col-names>
<item>Expression</item>
@@ -1155,7 +1155,7 @@
</BasePane-34050>
<MFCToolBar-34051>
<Name>Main</Name>
<Buttons>00200000010000002100FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000066000000FFFEFF000000000000000000000000000100000001000000018001E100000000000067000000FFFEFF000000000000000000000000000100000001000000018003E100000000000069000000FFFEFF000000000000000000000000000100000001000000018000810000000000004A000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000000006C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E10000000004006E000000FFFEFF000000000000000000000000000100000001000000018022E10000000004006D000000FFFEFF000000000000000000000000000100000001000000018025E100000000000070000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000000073000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040074000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6E4281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004005D000000FFFEFF000000000000000000000000000100000001000000018024E10000000000006F000000FFFEFF000000000000000000000000000100000001000000018028E100000000040071000000FFFEFF000000000000000000000000000100000001000000018029E100000000000072000000FFFEFF000000000000000000000000000100000001000000018002810000000000004C000000FFFEFF0000000000000000000000000001000000010000000180298100000000000061000000FFFEFF000000000000000000000000000100000001000000018027810000000000005F000000FFFEFF0000000000000000000000000001000000010000000180288100000000000060000000FFFEFF00000000000000000000000000010000000100000001801D8100000000040059000000FFFEFF00000000000000000000000000010000000100000001801E810000000004005A000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B8100000000000050000000FFFEFF00000000000000000000000000010000000100000001800C8100000000000051000000FFFEFF00000000000000000000000000010000000100000001805F8600000000000065000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001801F810000000000005B000000FFFEFF000000000000000000000000000100000001000000018020810000000000005C000000FFFEFF0000000000000000000000000001000000010000000180468100000000020063000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00FF020000</Buttons>
<Buttons>00200000010000002100FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000067000000FFFEFF000000000000000000000000000100000001000000018001E100000000000068000000FFFEFF000000000000000000000000000100000001000000018003E10000000000006A000000FFFEFF000000000000000000000000000100000001000000018000810000000000004B000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000000006D000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E10000000004006F000000FFFEFF000000000000000000000000000100000001000000018022E10000000004006E000000FFFEFF000000000000000000000000000100000001000000018025E100000000040071000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040074000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040075000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6E4281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000100FFFEFF0741007200720046006C006100670000000000018021810000000004005E000000FFFEFF000000000000000000000000000100000001000000018024E100000000000070000000FFFEFF000000000000000000000000000100000001000000018028E100000000040072000000FFFEFF000000000000000000000000000100000001000000018029E100000000000073000000FFFEFF000000000000000000000000000100000001000000018002810000000000004D000000FFFEFF0000000000000000000000000001000000010000000180298100000000000062000000FFFEFF0000000000000000000000000001000000010000000180278100000000000060000000FFFEFF0000000000000000000000000001000000010000000180288100000000000061000000FFFEFF00000000000000000000000000010000000100000001801D810000000004005A000000FFFEFF00000000000000000000000000010000000100000001801E810000000004005B000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B8100000000000051000000FFFEFF00000000000000000000000000010000000100000001800C8100000000000052000000FFFEFF00000000000000000000000000010000000100000001805F8600000000000066000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001801F810000000000005C000000FFFEFF000000000000000000000000000100000001000000018020810000000000005D000000FFFEFF0000000000000000000000000001000000010000000180468100000000020064000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00FF020000</Buttons>
</MFCToolBar-34051>
<Pane-34051>
<ID>34051</ID>


+ 10
- 7
EWARM/settings/PLSR.dnx Bestand weergeven

@@ -20,7 +20,7 @@
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
</StLinkDriver>
<DebugChecksum>
<Checksum>4029363809</Checksum>
<Checksum>234935861</Checksum>
</DebugChecksum>
<Exceptions>
<StopOnUncaught>_ 0</StopOnUncaught>
@@ -61,6 +61,9 @@
<regBase1>TIM2_ARR 10</regBase1>
<regBase2>TIM10_CNT 10</regBase2>
<regBase3>TIM10_ARR 10</regBase3>
<regBase4>TIM10_CCR1 10</regBase4>
<regBase5>TIM11_ARR 10</regBase5>
<regBase6>TIM11_CCR1 10</regBase6>
</Registers>
<struct_types>
<Fmt0>Option-AccDownTime 3 0</Fmt0>
@@ -76,10 +79,11 @@
<watch_formats>
<Fmt0>{W}1:AccITCount 3 0</Fmt0>
<Fmt1>{W}1:AllPulseCNT 3 0</Fmt1>
<Fmt2>{W}1:DatL 3 0</Fmt2>
<Fmt3>{W}1:arr 3 0</Fmt3>
<Fmt4>{W}1:c 4 0</Fmt4>
<Fmt5>{W}1:datCount 3 0</Fmt5>
<Fmt2>{W}1:ArrTimes 3 0</Fmt2>
<Fmt3>{W}1:DatL 3 0</Fmt3>
<Fmt4>{W}1:arr 3 0</Fmt4>
<Fmt5>{W}1:c 4 0</Fmt5>
<Fmt6>{W}1:datCount 3 0</Fmt6>
</watch_formats>
<Trace2>
<Enabled>0</Enabled>
@@ -152,8 +156,7 @@
<mode>0</mode>
</DisassembleMode>
<Breakpoints2>
<Bp0>_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\Core\Src\main.c}.644.5" 0 0 1 "" 0 "" 0</Bp0>
<Count>1</Count>
<Count>0</Count>
</Breakpoints2>
<Aliases>
<A0>_ "C:\Users\Chiri\Desktop\PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm" "C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm"</A0>


+ 16
- 16
EWARM/settings/Project.wsdt
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 4
- 36
EWARM/settings/Project_EditorBookmarks.xml Bestand weergeven

@@ -2,46 +2,14 @@
<userBookmarks>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>375</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>436</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>466</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>342</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>560</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>339</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>372</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>433</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>463</row>
<row>638</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>557</row>
<row>552</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>638</row>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\stm32f4xx_it.c</path>
<row>239</row>
</bookmark>
</userBookmarks>

+ 22
- 24
Hardware/PLSR.c Bestand weergeven

@@ -33,12 +33,13 @@ int32_t PulseCount = 0;
void SetFrequency(uint8_t SentPost, uint32_t Frequency)
{
CalculatePSCARR(Frequency, 72000000, 65535, &psc, &arr);
//Frequency_Change_PSC_And_ARR(Frequency, &psc, &arr);
//printf("Fre=%d,",Frequency);
switch (SentPost)
{
case 0: TIM10->ARR = arr, TIM10->PSC = psc, TIM10->CCR1 = arr / 2; break;
case 1: TIM11->ARR = arr, TIM11->PSC = psc, TIM11->CCR1 = arr / 2; break;
case 2: TIM13->ARR = arr, TIM13->PSC = psc, TIM13->CCR1 = arr / 2; break;
case 1: TIM13->ARR = arr, TIM13->PSC = psc, TIM13->CCR1 = arr / 2; break;
case 2: TIM11->ARR = arr, TIM11->PSC = psc, TIM11->CCR1 = arr / 2; break;
case 3: TIM14->ARR = arr, TIM14->PSC = psc, TIM14->CCR1 = arr / 2; break;
}
@@ -46,7 +47,6 @@ void SetFrequency(uint8_t SentPost, uint32_t Frequency)

/**
* @brief Âö³å¿ªÊ¼
* @param[in] StartPulse ÆðʼÂö³å¶Î
* @return ÎÞ
*/
void PulseStart(void)
@@ -55,11 +55,25 @@ void PulseStart(void)
switch(Options.SentPost)
{
case 0: HAL_TIM_PWM_Start(&htim10, TIM_CHANNEL_1); break;
case 1: HAL_TIM_PWM_Start(&htim11, TIM_CHANNEL_1); break;
case 2: HAL_TIM_PWM_Start(&htim13, TIM_CHANNEL_1); break;
case 1: HAL_TIM_PWM_Start(&htim13, TIM_CHANNEL_1); break;
case 2: HAL_TIM_PWM_Start(&htim11, TIM_CHANNEL_1); break;
case 3: HAL_TIM_PWM_Start(&htim14, TIM_CHANNEL_1); break;
}
}

/**
* @brief Âö³å½áÊø
* @return ÎÞ
*/
void PulseEnd(void)
{
switch(Options.SentPost)
{
case 0: HAL_TIM_PWM_Stop_IT(&htim10, TIM_CHANNEL_1); break;
case 1: HAL_TIM_PWM_Stop_IT(&htim13, TIM_CHANNEL_1); break;
case 2: HAL_TIM_PWM_Stop_IT(&htim11, TIM_CHANNEL_1); break;
case 3: HAL_TIM_PWM_Stop_IT(&htim14, TIM_CHANNEL_1); break;
}
}

/**
@@ -85,27 +99,11 @@ void SetNextPulse(void)
{
if (PulseOutput[NowPulse].PulseCount > 0)
{
if (Options.AllPulse - PulseNum == 1)
{
TIM2->ARR = PulseOutput[NowPulse].PulseCount - N_Acc;
}
else
{
TIM2->ARR = PulseOutput[NowPulse].PulseCount;
}
TIM2->ARR = PulseOutput[NowPulse].PulseCount;
}
else
{
if (Options.AllPulse - PulseNum == 1)
{
TIM2->ARR = - PulseOutput[NowPulse].PulseCount - N_Acc;
}
else
{
TIM2->ARR = - PulseOutput[NowPulse].PulseCount;
}
TIM2->ARR = - PulseOutput[NowPulse].PulseCount;
}
}


+ 1
- 0
Hardware/PLSR.h Bestand weergeven

@@ -48,6 +48,7 @@ extern int32_t NextPulseEND;
/* 函数声明 */
void SetFrequency(uint8_t SentPost, uint32_t Frequency);
void PulseStart(void);
void PulseEnd(void);
float GetAcc(int32_t Start, int32_t End, int32_t AccCount);
void SetNextPulse(void);
void PLSROptionLoad(void);


+ 1
- 6
Hardware/PSCARR.c Bestand weergeven

@@ -123,8 +123,7 @@ void Frequency_Change_PSC_And_ARR(uint32_t Frequency, uint16_t* psc, uint16_t* a
{
if (Frequency <= 1098)
{
*psc = ARRPSC[Frequency - 1][0];
*arr = ARRPSC[Frequency - 1][1];
CalculatePSCARR(Frequency, 72000000, 65535, psc, arr);
}
else
{
@@ -132,10 +131,6 @@ void Frequency_Change_PSC_And_ARR(uint32_t Frequency, uint16_t* psc, uint16_t* a
*arr = 36000000 / ((*psc) * Frequency);
}
}
else
{
//printf("输入频率不在1~100k之间。\n");
}
}




+ 15
- 3
PLSR.ioc Bestand weergeven

@@ -221,12 +221,24 @@ TIM10.OCPolarity_1=TIM_OCPOLARITY_LOW
TIM10.Period=1
TIM10.Prescaler=1
TIM10.Pulse=0
TIM11.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM11.Channel=TIM_CHANNEL_1
TIM11.IPParameters=Channel
TIM11.IPParameters=Channel,Prescaler,Period,AutoReloadPreload,OCPolarity_1
TIM11.OCPolarity_1=TIM_OCPOLARITY_LOW
TIM11.Period=1
TIM11.Prescaler=1
TIM13.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM13.Channel=TIM_CHANNEL_1
TIM13.IPParameters=Channel
TIM13.IPParameters=Channel,AutoReloadPreload,Period,Prescaler,OCPolarity_1
TIM13.OCPolarity_1=TIM_OCPOLARITY_LOW
TIM13.Period=1
TIM13.Prescaler=1
TIM14.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM14.Channel=TIM_CHANNEL_1
TIM14.IPParameters=Channel
TIM14.IPParameters=Channel,Prescaler,Period,AutoReloadPreload,OCPolarity_1
TIM14.OCPolarity_1=TIM_OCPOLARITY_LOW
TIM14.Period=1
TIM14.Prescaler=1
TIM3.IPParameters=Prescaler,Period
TIM3.Period=999
TIM3.Prescaler=72-1


BIN
Words/测试大纲.doc Bestand weergeven


BIN
Words/设计方案书 .doc Bestand weergeven


Laden…
Annuleren
Opslaan