| @@ -55,6 +55,7 @@ void SVC_Handler(void); | |||||
| void DebugMon_Handler(void); | void DebugMon_Handler(void); | ||||
| void PendSV_Handler(void); | void PendSV_Handler(void); | ||||
| void SysTick_Handler(void); | void SysTick_Handler(void); | ||||
| void TIM1_UP_TIM10_IRQHandler(void); | |||||
| void TIM2_IRQHandler(void); | void TIM2_IRQHandler(void); | ||||
| void USART1_IRQHandler(void); | void USART1_IRQHandler(void); | ||||
| void DMA2_Stream2_IRQHandler(void); | void DMA2_Stream2_IRQHandler(void); | ||||
| @@ -48,6 +48,8 @@ void MX_GPIO_Init(void) | |||||
| __HAL_RCC_GPIOF_CLK_ENABLE(); | __HAL_RCC_GPIOF_CLK_ENABLE(); | ||||
| __HAL_RCC_GPIOH_CLK_ENABLE(); | __HAL_RCC_GPIOH_CLK_ENABLE(); | ||||
| __HAL_RCC_GPIOA_CLK_ENABLE(); | __HAL_RCC_GPIOA_CLK_ENABLE(); | ||||
| __HAL_RCC_GPIOG_CLK_ENABLE(); | |||||
| __HAL_RCC_GPIOB_CLK_ENABLE(); | |||||
| /*Configure GPIO pin Output Level */ | /*Configure GPIO pin Output Level */ | ||||
| HAL_GPIO_WritePin(GPIOH, Y15_Pin|Y14_Pin|Y13_Pin|Y12_Pin, GPIO_PIN_RESET); | HAL_GPIO_WritePin(GPIOH, Y15_Pin|Y14_Pin|Y13_Pin|Y12_Pin, GPIO_PIN_RESET); | ||||
| @@ -59,6 +61,18 @@ void MX_GPIO_Init(void) | |||||
| GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||||
| HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); | HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); | ||||
| /*Configure GPIO pin : PG12 */ | |||||
| GPIO_InitStruct.Pin = GPIO_PIN_12; | |||||
| GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |||||
| GPIO_InitStruct.Pull = GPIO_NOPULL; | |||||
| HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); | |||||
| /*Configure GPIO pin : PB5 */ | |||||
| GPIO_InitStruct.Pin = GPIO_PIN_5; | |||||
| GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |||||
| GPIO_InitStruct.Pull = GPIO_NOPULL; | |||||
| HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | |||||
| } | } | ||||
| /* USER CODE BEGIN 2 */ | /* USER CODE BEGIN 2 */ | ||||
| @@ -29,6 +29,8 @@ | |||||
| #include "includes.h" | #include "includes.h" | ||||
| #include "modbus.h" | #include "modbus.h" | ||||
| #include "bitset.h" | #include "bitset.h" | ||||
| /* USER CODE END Includes */ | /* USER CODE END Includes */ | ||||
| /* Private typedef -----------------------------------------------------------*/ | /* Private typedef -----------------------------------------------------------*/ | ||||
| @@ -38,8 +40,9 @@ float Acc; /* | |||||
| int32_t AllPulseCNT = 0; | int32_t AllPulseCNT = 0; | ||||
| int32_t BaseCNT = 0; | int32_t BaseCNT = 0; | ||||
| uint8_t EndFlag = 0; | |||||
| uint8_t FullFlag = 0; | |||||
| uint8_t AccITCount = 0; | |||||
| uint8_t PulseStartFlag = 0; | |||||
| extern uint8_t Register_H[16384]; ///<寄存器的高字节 | extern uint8_t Register_H[16384]; ///<寄存器的高字节 | ||||
| extern uint8_t Register_L[16384]; ///<寄存器的低字节 | extern uint8_t Register_L[16384]; ///<寄存器的低字节 | ||||
| @@ -72,7 +75,7 @@ void PVD_Init(void); | |||||
| /* 任务优先级 */ | /* 任务优先级 */ | ||||
| #define TASK_Y1Direction 4 | #define TASK_Y1Direction 4 | ||||
| #define TASK_PulseStart 4 | |||||
| #define TASK_PulseStart 3 | |||||
| #define TASK_DirOutput 4 | #define TASK_DirOutput 4 | ||||
| /* 任务堆栈大小 */ | /* 任务堆栈大小 */ | ||||
| @@ -279,7 +282,7 @@ void Y1Direction(void *p_arg) | |||||
| /* 脉冲加速 */ | /* 脉冲加速 */ | ||||
| if (Acc > 0) | if (Acc > 0) | ||||
| { | { | ||||
| if (TIM2->CNT < AccUpCount) | |||||
| if (TIM2->CNT <= AccUpCount) | |||||
| { | { | ||||
| SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + TIM2->CNT * Acc); | SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + TIM2->CNT * Acc); | ||||
| if (TIM2->CNT == 0) PulseStart(); /* 开始产生脉冲 */ | if (TIM2->CNT == 0) PulseStart(); /* 开始产生脉冲 */ | ||||
| @@ -293,7 +296,7 @@ void Y1Direction(void *p_arg) | |||||
| /* 脉冲减速 */ | /* 脉冲减速 */ | ||||
| else if (Acc <= 0) | else if (Acc <= 0) | ||||
| { | { | ||||
| if (TIM2->CNT < AccDownCount) | |||||
| if (TIM2->CNT <= AccDownCount) | |||||
| { | { | ||||
| SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + TIM2->CNT * Acc); | SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + TIM2->CNT * Acc); | ||||
| if(TIM2->CNT == 0) PulseStart(); /* 开始产生脉冲 */ | if(TIM2->CNT == 0) PulseStart(); /* 开始产生脉冲 */ | ||||
| @@ -303,42 +306,9 @@ void Y1Direction(void *p_arg) | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | ||||
| ArrFlag = 0; | ArrFlag = 0; | ||||
| } | } | ||||
| } | |||||
| } | |||||
| /* 最后一段脉冲的减速 */ | |||||
| if (NowPulse == Options.AllPulse - 1) | |||||
| { | |||||
| Acc = - (float)PulseOutput[NowPulse].Frequency / (float)AccDownCount;/* 计算加速度 */ | |||||
| if (TIM2->CNT > PulseOutput[NowPulse].PulseCount - AccUpCount - AccDownCount) /* 当达到脉冲减速的位置开始减速 */ | |||||
| { | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency + TIM2->CNT * Acc); | |||||
| } | |||||
| } | |||||
| /* 第一段脉冲的加速 */ | |||||
| if (NowPulse == Options.StartPulse) | |||||
| { | |||||
| Acc = (float)PulseOutput[NowPulse].Frequency / (float)AccUpCount;/* 计算加速度 */ | |||||
| if (AccUpCount < PulseOutput[NowPulse].PulseCount)//如果能够完成加速 | |||||
| { | |||||
| if(TIM2->CNT < AccUpCount) | |||||
| { | |||||
| SetFrequency(Options.SentPost, TIM2->CNT * Acc); | |||||
| } | |||||
| else | |||||
| { | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | |||||
| } | |||||
| } | |||||
| else //不能完成加速 | |||||
| { | |||||
| } | |||||
| } | |||||
| } | } | ||||
| AllPulseCNT = BaseCNT + TIM2->CNT; | AllPulseCNT = BaseCNT + TIM2->CNT; | ||||
| CountSave(); | CountSave(); | ||||
| @@ -363,18 +333,53 @@ void PulseStartTsk(void *p_arg) | |||||
| PLSROptionLoad(); //读取脉冲基础设置 | PLSROptionLoad(); //读取脉冲基础设置 | ||||
| if(Register_L[0x3000] == 0x01 && EN == 1) | if(Register_L[0x3000] == 0x01 && EN == 1) | ||||
| { | |||||
| { | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | |||||
| PulseStart(); | PulseStart(); | ||||
| EN = 0; | EN = 0; | ||||
| PulseStartFlag = 1; | |||||
| } | } | ||||
| else if(Register_L[0x3000] == 0x02 && EN == 0) | else if(Register_L[0x3000] == 0x02 && EN == 0) | ||||
| { | { | ||||
| EN = 1; | EN = 1; | ||||
| } | } | ||||
| ModbusSaveSRAM(); | |||||
| ModbusSaveSRAM(); | |||||
| /* 第一段脉冲的加速 */ | |||||
| if (NowPulse == Options.StartPulse && PulseStartFlag == 1) | |||||
| { | |||||
| Acc = (float)PulseOutput[NowPulse].Frequency / (float)AccUpCount;/* 计算加速度 */ | |||||
| if (AccUpCount < PulseOutput[NowPulse].PulseCount)//如果能够完成加速 | |||||
| { | |||||
| if(TIM2->CNT < AccUpCount) | |||||
| { | |||||
| SetFrequency(Options.SentPost, TIM2->CNT * Acc); | |||||
| } | |||||
| else | |||||
| { | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | |||||
| PulseStartFlag = 0; | |||||
| } | |||||
| } | |||||
| else //不能完成加速 | |||||
| { | |||||
| } | |||||
| } | |||||
| OSTimeDly(100, OS_OPT_TIME_DLY, &err); // 延时 100 个节拍 | |||||
| /* 最后一段脉冲的减速 */ | |||||
| if (NowPulse == Options.AllPulse - 1) | |||||
| { | |||||
| Acc = - (float)PulseOutput[NowPulse].Frequency / (float)AccDownCount;/* 计算加速度 */ | |||||
| if (TIM2->CNT > PulseOutput[NowPulse].PulseCount - AccUpCount - AccDownCount) /* 当达到脉冲减速的位置开始减速 */ | |||||
| { | |||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency + TIM2->CNT * Acc); | |||||
| } | |||||
| } | |||||
| OSTimeDly(10, OS_OPT_TIME_DLY, &err); // 延时 10 个节拍 | |||||
| } | } | ||||
| } | } | ||||
| @@ -440,6 +445,7 @@ void DirOutput(void *p_arg) | |||||
| } | } | ||||
| } | } | ||||
| /* USER CODE END 4 */ | /* USER CODE END 4 */ | ||||
| /** | /** | ||||
| @@ -61,6 +61,7 @@ | |||||
| /* External variables --------------------------------------------------------*/ | /* External variables --------------------------------------------------------*/ | ||||
| extern TIM_HandleTypeDef htim2; | extern TIM_HandleTypeDef htim2; | ||||
| extern TIM_HandleTypeDef htim10; | |||||
| extern DMA_HandleTypeDef hdma_usart1_rx; | extern DMA_HandleTypeDef hdma_usart1_rx; | ||||
| extern DMA_HandleTypeDef hdma_usart1_tx; | extern DMA_HandleTypeDef hdma_usart1_tx; | ||||
| extern UART_HandleTypeDef huart1; | extern UART_HandleTypeDef huart1; | ||||
| @@ -206,6 +207,20 @@ void SysTick_Handler(void) | |||||
| /* please refer to the startup file (startup_stm32f4xx.s). */ | /* please refer to the startup file (startup_stm32f4xx.s). */ | ||||
| /******************************************************************************/ | /******************************************************************************/ | ||||
| /** | |||||
| * @brief This function handles TIM1 update interrupt and TIM10 global interrupt. | |||||
| */ | |||||
| void TIM1_UP_TIM10_IRQHandler(void) | |||||
| { | |||||
| /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */ | |||||
| /* USER CODE END TIM1_UP_TIM10_IRQn 0 */ | |||||
| HAL_TIM_IRQHandler(&htim10); | |||||
| /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */ | |||||
| /* USER CODE END TIM1_UP_TIM10_IRQn 1 */ | |||||
| } | |||||
| /** | /** | ||||
| * @brief This function handles TIM2 global interrupt. | * @brief This function handles TIM2 global interrupt. | ||||
| */ | */ | ||||
| @@ -246,19 +261,17 @@ void TIM2_IRQHandler(void) | |||||
| { | { | ||||
| Acc = GetAcc(PulseOutput[PrePulse].Frequency, | Acc = GetAcc(PulseOutput[PrePulse].Frequency, | ||||
| PulseOutput[NowPulse].Frequency, Options.AccDownTime); /* 计算加速度 */ | PulseOutput[NowPulse].Frequency, Options.AccDownTime); /* 计算加速度 */ | ||||
| } | |||||
| ArrFlag = 1; | |||||
| SetNextPulse();/* 设置下一次进入中断的脉冲数 */ | |||||
| } | |||||
| ArrFlag = 1; | |||||
| SetNextPulse();/* 设置下一次进入中断的脉冲数 */ | |||||
| } | } | ||||
| /* 如果之后没有脉冲 */ | /* 如果之后没有脉冲 */ | ||||
| else | else | ||||
| { | { | ||||
| PulseCount = 0; | PulseCount = 0; | ||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| EndFlag = 1; | |||||
| ArrFlag = 0; | |||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| } | } | ||||
| } | } | ||||
| if(Options.RunMod == 1) | if(Options.RunMod == 1) | ||||
| @@ -266,8 +279,7 @@ void TIM2_IRQHandler(void) | |||||
| if(AllPulseCNT >= MAX_Pulse) | if(AllPulseCNT >= MAX_Pulse) | ||||
| { | { | ||||
| PulseCount = 0; | PulseCount = 0; | ||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| FullFlag = 1; | |||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -296,8 +308,7 @@ void TIM2_IRQHandler(void) | |||||
| else | else | ||||
| { | { | ||||
| PulseCount = 0; | PulseCount = 0; | ||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| EndFlag = 1; | |||||
| HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -114,10 +114,7 @@ void MX_TIM10_Init(void) | |||||
| __HAL_TIM_CLEAR_IT(&htim10, TIM_IT_UPDATE); | __HAL_TIM_CLEAR_IT(&htim10, TIM_IT_UPDATE); | ||||
| TIM10->SR = 0; // 直接清除状态寄存器 | TIM10->SR = 0; // 直接清除状态寄存器 | ||||
| TIM_MasterConfigTypeDef sMasterConfig = {0}; | |||||
| sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; // TRGO信号源为更新事件 | |||||
| sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; // 仅主模式 | |||||
| HAL_TIMEx_MasterConfigSynchronization(&htim10, &sMasterConfig); | |||||
| /* USER CODE END TIM10_Init 2 */ | /* USER CODE END TIM10_Init 2 */ | ||||
| HAL_TIM_MspPostInit(&htim10); | HAL_TIM_MspPostInit(&htim10); | ||||
| @@ -283,6 +280,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle) | |||||
| /* USER CODE END TIM10_MspInit 0 */ | /* USER CODE END TIM10_MspInit 0 */ | ||||
| /* TIM10 clock enable */ | /* TIM10 clock enable */ | ||||
| __HAL_RCC_TIM10_CLK_ENABLE(); | __HAL_RCC_TIM10_CLK_ENABLE(); | ||||
| /* TIM10 interrupt Init */ | |||||
| HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0); | |||||
| HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); | |||||
| /* USER CODE BEGIN TIM10_MspInit 1 */ | /* USER CODE BEGIN TIM10_MspInit 1 */ | ||||
| /* USER CODE END TIM10_MspInit 1 */ | /* USER CODE END TIM10_MspInit 1 */ | ||||
| @@ -440,6 +441,9 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle) | |||||
| /* USER CODE END TIM10_MspDeInit 0 */ | /* USER CODE END TIM10_MspDeInit 0 */ | ||||
| /* Peripheral clock disable */ | /* Peripheral clock disable */ | ||||
| __HAL_RCC_TIM10_CLK_DISABLE(); | __HAL_RCC_TIM10_CLK_DISABLE(); | ||||
| /* TIM10 interrupt Deinit */ | |||||
| HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); | |||||
| /* USER CODE BEGIN TIM10_MspDeInit 1 */ | /* USER CODE BEGIN TIM10_MspDeInit 1 */ | ||||
| /* USER CODE END TIM10_MspDeInit 1 */ | /* USER CODE END TIM10_MspDeInit 1 */ | ||||
| @@ -21,6 +21,25 @@ | |||||
| #include "usart.h" | #include "usart.h" | ||||
| /* USER CODE BEGIN 0 */ | /* USER CODE BEGIN 0 */ | ||||
| #ifdef USE_printf | |||||
| #include <stdio.h> | |||||
| #ifdef __GNUC__ | |||||
| #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) | |||||
| #else | |||||
| #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) | |||||
| #endif | |||||
| PUTCHAR_PROTOTYPE | |||||
| { | |||||
| HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 100); | |||||
| return ch; | |||||
| } | |||||
| #endif | |||||
| uint8_t RX1DataTemp = 0; | uint8_t RX1DataTemp = 0; | ||||
| uint8_t RX1Data[RX_BUFFER_SIZE] = {0}; | uint8_t RX1Data[RX_BUFFER_SIZE] = {0}; | ||||
| uint8_t RX1Flag = 0; | uint8_t RX1Flag = 0; | ||||
| @@ -226,6 +226,7 @@ | |||||
| <name>CCDefines</name> | <name>CCDefines</name> | ||||
| <state>USE_HAL_DRIVER</state> | <state>USE_HAL_DRIVER</state> | ||||
| <state>STM32F407xx</state> | <state>STM32F407xx</state> | ||||
| <state>USE_printf</state> | |||||
| </option> | </option> | ||||
| <option> | <option> | ||||
| <name>CCPreprocFile</name> | <name>CCPreprocFile</name> | ||||
| @@ -20,7 +20,7 @@ | |||||
| <LeaveTargetRunning>_ 0</LeaveTargetRunning> | <LeaveTargetRunning>_ 0</LeaveTargetRunning> | ||||
| </StLinkDriver> | </StLinkDriver> | ||||
| <DebugChecksum> | <DebugChecksum> | ||||
| <Checksum>3713707742</Checksum> | |||||
| <Checksum>3456179106</Checksum> | |||||
| </DebugChecksum> | </DebugChecksum> | ||||
| <Exceptions> | <Exceptions> | ||||
| <StopOnUncaught>_ 0</StopOnUncaught> | <StopOnUncaught>_ 0</StopOnUncaught> | ||||
| @@ -58,6 +58,7 @@ | |||||
| </SWOTraceHWSettings> | </SWOTraceHWSettings> | ||||
| <Registers> | <Registers> | ||||
| <regBase0>TIM2_CNT 10</regBase0> | <regBase0>TIM2_CNT 10</regBase0> | ||||
| <regBase1>TIM2_ARR 10</regBase1> | |||||
| </Registers> | </Registers> | ||||
| <struct_types> | <struct_types> | ||||
| <Fmt0>Option-AccDownTime 3 0</Fmt0> | <Fmt0>Option-AccDownTime 3 0</Fmt0> | ||||
| @@ -71,9 +72,10 @@ | |||||
| <Fmt0>uint8_t[10000] 4 0</Fmt0> | <Fmt0>uint8_t[10000] 4 0</Fmt0> | ||||
| </array_types> | </array_types> | ||||
| <watch_formats> | <watch_formats> | ||||
| <Fmt0>{W}1:AllPulseCNT 3 0</Fmt0> | |||||
| <Fmt1>{W}1:c 4 0</Fmt1> | |||||
| <Fmt2>{W}1:datCount 3 0</Fmt2> | |||||
| <Fmt0>{W}1:AccITCount 3 0</Fmt0> | |||||
| <Fmt1>{W}1:AllPulseCNT 3 0</Fmt1> | |||||
| <Fmt2>{W}1:c 4 0</Fmt2> | |||||
| <Fmt3>{W}1:datCount 3 0</Fmt3> | |||||
| </watch_formats> | </watch_formats> | ||||
| <Trace2> | <Trace2> | ||||
| <Enabled>0</Enabled> | <Enabled>0</Enabled> | ||||
| @@ -6,6 +6,8 @@ | |||||
| #include "modbus.h" | #include "modbus.h" | ||||
| #include "bitset.h" | #include "bitset.h" | ||||
| #include <stdio.h> | |||||
| Pulse PulseOutput[10]; // Ê®¶ÎÂö³åµÄÅäÖà | Pulse PulseOutput[10]; // Ê®¶ÎÂö³åµÄÅäÖà | ||||
| Option Options; | Option Options; | ||||
| @@ -29,6 +31,7 @@ int32_t PulseCount = 0; | |||||
| void SetFrequency(uint8_t SentPost, uint32_t Frequency) | void SetFrequency(uint8_t SentPost, uint32_t Frequency) | ||||
| { | { | ||||
| Frequency_Change_PSC_And_ARR(Frequency, &psc, &arr); | Frequency_Change_PSC_And_ARR(Frequency, &psc, &arr); | ||||
| printf("Fre=%d,",Frequency); | |||||
| switch(SentPost) | switch(SentPost) | ||||
| { | { | ||||
| case 0: TIM10->ARR = arr, TIM10->PSC = psc, TIM10->CCR1 = arr / 2; break; | case 0: TIM10->ARR = arr, TIM10->PSC = psc, TIM10->CCR1 = arr / 2; break; | ||||
| @@ -77,7 +80,6 @@ void PulseBaseInit(uint8_t StartPulse, uint8_t PulseMod, int32_t MAX_Pulse) | |||||
| */ | */ | ||||
| void PulseStart(void) | void PulseStart(void) | ||||
| { | { | ||||
| SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | |||||
| TIM2->ARR = PulseOutput[NowPulse].PulseCount; | TIM2->ARR = PulseOutput[NowPulse].PulseCount; | ||||
| switch(Options.SentPost) | switch(Options.SentPost) | ||||
| @@ -235,7 +237,7 @@ void PLSROptionLoad(void) | |||||
| Options.AccMod = Register_L[0x1005]; | Options.AccMod = Register_L[0x1005]; | ||||
| Options.RunMod = Register_L[0x1006]; | Options.RunMod = Register_L[0x1006]; | ||||
| Options.AllPulse = Register_L[0x1007]; | Options.AllPulse = Register_L[0x1007]; | ||||
| Options.StartPulse = Register_L[0x1008]; | |||||
| Options.StartPulse = Register_L[0x1008] - 1; | |||||
| Options.InitSpeed = InitSpeed; | Options.InitSpeed = InitSpeed; | ||||
| Options.AccUpTime = (Register_H[0x100B]<< 8) | Register_L[0x100B]; | Options.AccUpTime = (Register_H[0x100B]<< 8) | Register_L[0x100B]; | ||||
| Options.AccDownTime = (Register_H[0x100C]<< 8) | Register_L[0x100C]; | Options.AccDownTime = (Register_H[0x100C]<< 8) | Register_L[0x100C]; | ||||
| @@ -293,6 +295,14 @@ void CountSave(void) | |||||
| */ | */ | ||||
| void GetAddCount(void) | void GetAddCount(void) | ||||
| { | { | ||||
| AccUpCount = Options.AccUpTime * PulseOutput[NowPulse].Frequency / 1000; | |||||
| AccDownCount = Options.AccDownTime * PulseOutput[NowPulse].Frequency / 1000; | |||||
| if(NowPulse == Options.StartPulse) | |||||
| { | |||||
| AccUpCount = Options.AccUpTime * PulseOutput[NowPulse].Frequency / 1000; | |||||
| } | |||||
| else | |||||
| { | |||||
| AccUpCount = Options.AccUpTime * (PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / 1000; | |||||
| AccDownCount = Options.AccDownTime * (PulseOutput[PrePulse].Frequency - PulseOutput[NowPulse].Frequency) / 1000; | |||||
| } | |||||
| } | } | ||||
| @@ -50,12 +50,14 @@ Mcu.Pin11=PA10 | |||||
| Mcu.Pin12=PA13 | Mcu.Pin12=PA13 | ||||
| Mcu.Pin13=PA14 | Mcu.Pin13=PA14 | ||||
| Mcu.Pin14=PA15 | Mcu.Pin14=PA15 | ||||
| Mcu.Pin15=VP_SYS_VS_Systick | |||||
| Mcu.Pin16=VP_TIM10_VS_ClockSourceINT | |||||
| Mcu.Pin17=VP_TIM11_VS_ClockSourceINT | |||||
| Mcu.Pin18=VP_TIM13_VS_ClockSourceINT | |||||
| Mcu.Pin19=VP_TIM14_VS_ClockSourceINT | |||||
| Mcu.Pin15=PG12 | |||||
| Mcu.Pin16=PB5 | |||||
| Mcu.Pin17=VP_SYS_VS_Systick | |||||
| Mcu.Pin18=VP_TIM10_VS_ClockSourceINT | |||||
| Mcu.Pin19=VP_TIM11_VS_ClockSourceINT | |||||
| Mcu.Pin2=PF8 | Mcu.Pin2=PF8 | ||||
| Mcu.Pin20=VP_TIM13_VS_ClockSourceINT | |||||
| Mcu.Pin21=VP_TIM14_VS_ClockSourceINT | |||||
| Mcu.Pin3=PF9 | Mcu.Pin3=PF9 | ||||
| Mcu.Pin4=PH0-OSC_IN | Mcu.Pin4=PH0-OSC_IN | ||||
| Mcu.Pin5=PH1-OSC_OUT | Mcu.Pin5=PH1-OSC_OUT | ||||
| @@ -63,7 +65,7 @@ Mcu.Pin6=PH6 | |||||
| Mcu.Pin7=PH7 | Mcu.Pin7=PH7 | ||||
| Mcu.Pin8=PH8 | Mcu.Pin8=PH8 | ||||
| Mcu.Pin9=PH9 | Mcu.Pin9=PH9 | ||||
| Mcu.PinsNb=20 | |||||
| Mcu.PinsNb=22 | |||||
| Mcu.ThirdPartyNb=0 | Mcu.ThirdPartyNb=0 | ||||
| Mcu.UserConstants= | Mcu.UserConstants= | ||||
| Mcu.UserName=STM32F407IGTx | Mcu.UserName=STM32F407IGTx | ||||
| @@ -81,6 +83,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false | |||||
| NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 | ||||
| NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false | ||||
| NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false | NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false | ||||
| NVIC.TIM1_UP_TIM10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true | |||||
| NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true | NVIC.TIM2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true | ||||
| NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true | NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true | ||||
| NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false | ||||
| @@ -96,6 +99,8 @@ PA15.Locked=true | |||||
| PA15.Signal=S_TIM2_CH1_ETR | PA15.Signal=S_TIM2_CH1_ETR | ||||
| PA9.Mode=Asynchronous | PA9.Mode=Asynchronous | ||||
| PA9.Signal=USART1_TX | PA9.Signal=USART1_TX | ||||
| PB5.Locked=true | |||||
| PB5.Signal=GPIO_Input | |||||
| PF6.Locked=true | PF6.Locked=true | ||||
| PF6.Signal=S_TIM10_CH1 | PF6.Signal=S_TIM10_CH1 | ||||
| PF7.Locked=true | PF7.Locked=true | ||||
| @@ -104,6 +109,8 @@ PF8.Locked=true | |||||
| PF8.Signal=S_TIM13_CH1 | PF8.Signal=S_TIM13_CH1 | ||||
| PF9.Locked=true | PF9.Locked=true | ||||
| PF9.Signal=S_TIM14_CH1 | PF9.Signal=S_TIM14_CH1 | ||||
| PG12.Locked=true | |||||
| PG12.Signal=GPIO_Input | |||||
| PH0-OSC_IN.Mode=HSE-External-Oscillator | PH0-OSC_IN.Mode=HSE-External-Oscillator | ||||
| PH0-OSC_IN.Signal=RCC_OSC_IN | PH0-OSC_IN.Signal=RCC_OSC_IN | ||||
| PH1-OSC_OUT.Mode=HSE-External-Oscillator | PH1-OSC_OUT.Mode=HSE-External-Oscillator | ||||