partially solved issue with random modulator and ADC clock stopping at the end of ЛЧМ. Done: when we want to stop clocks -- enable IRQ on sloewr clock (TIM11). In IRQ switches TIM4, TIM11 to one-pulse mode, disables IRQ. When we starting these timers th next time -- we resets their counters, one-pulse mode disables.
This commit is contained in:
@ -185,6 +185,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\:0\:0\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false
|
||||||
|
NVIC.TIM1_TRG_COM_TIM11_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
NVIC.TIM1_UP_TIM10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
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.TIM5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
NVIC.TIM5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||||
|
|||||||
@ -57,6 +57,7 @@ void PendSV_Handler(void);
|
|||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
void ADC_IRQHandler(void);
|
void ADC_IRQHandler(void);
|
||||||
void TIM1_UP_TIM10_IRQHandler(void);
|
void TIM1_UP_TIM10_IRQHandler(void);
|
||||||
|
void TIM1_TRG_COM_TIM11_IRQHandler(void);
|
||||||
void TIM2_IRQHandler(void);
|
void TIM2_IRQHandler(void);
|
||||||
void USART1_IRQHandler(void);
|
void USART1_IRQHandler(void);
|
||||||
void TIM8_UP_TIM13_IRQHandler(void);
|
void TIM8_UP_TIM13_IRQHandler(void);
|
||||||
|
|||||||
22
Src/main.c
22
Src/main.c
@ -421,8 +421,19 @@ int main(void)
|
|||||||
uint16_t trigger_counter = 0;
|
uint16_t trigger_counter = 0;
|
||||||
uint16_t trigger_step = (uint8_t )((task.max_param - task.current_param)/task.delta_param * 10);
|
uint16_t trigger_step = (uint8_t )((task.max_param - task.current_param)/task.delta_param * 10);
|
||||||
uint16_t task_sheduler = 0;
|
uint16_t task_sheduler = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
|
||||||
|
HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
|
||||||
|
TIM11 -> CR1 &= ~(1 << 3); //disables one-pulse mode
|
||||||
|
TIM4 -> CR1 &= ~(1 << 3); //disables one-pulse mode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TIM11 -> CNT = 0;
|
TIM11 -> CNT = 0;
|
||||||
TIM4 -> CNT = 0;
|
TIM4 -> CNT = 0;
|
||||||
|
|
||||||
HAL_TIM_PWM_Start(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
|
HAL_TIM_PWM_Start(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
|
||||||
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
|
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
|
||||||
while (task.current_param < task.max_param)
|
while (task.current_param < task.max_param)
|
||||||
@ -468,8 +479,15 @@ int main(void)
|
|||||||
//*/
|
//*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
|
TIM11 -> DIER |= 1; //enable update interrupt. In this IRQ handler we will set both tims to one-pulse mode.
|
||||||
HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
|
//TIM11 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
|
||||||
|
//TIM4 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
|
||||||
|
//but one-pulse mode should be disabled
|
||||||
|
|
||||||
|
//HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
|
||||||
|
//HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Stop_TIM10();
|
Stop_TIM10();
|
||||||
|
|
||||||
|
|||||||
@ -378,6 +378,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
|||||||
/* USER CODE END TIM11_MspInit 0 */
|
/* USER CODE END TIM11_MspInit 0 */
|
||||||
/* Peripheral clock enable */
|
/* Peripheral clock enable */
|
||||||
__HAL_RCC_TIM11_CLK_ENABLE();
|
__HAL_RCC_TIM11_CLK_ENABLE();
|
||||||
|
/* TIM11 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM11_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM11_IRQn);
|
||||||
/* USER CODE BEGIN TIM11_MspInit 1 */
|
/* USER CODE BEGIN TIM11_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM11_MspInit 1 */
|
/* USER CODE END TIM11_MspInit 1 */
|
||||||
@ -485,6 +488,9 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
|||||||
/* USER CODE END TIM11_MspDeInit 0 */
|
/* USER CODE END TIM11_MspDeInit 0 */
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_TIM11_CLK_DISABLE();
|
__HAL_RCC_TIM11_CLK_DISABLE();
|
||||||
|
|
||||||
|
/* TIM11 interrupt DeInit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM1_TRG_COM_TIM11_IRQn);
|
||||||
/* USER CODE BEGIN TIM11_MspDeInit 1 */
|
/* USER CODE BEGIN TIM11_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM11_MspDeInit 1 */
|
/* USER CODE END TIM11_MspDeInit 1 */
|
||||||
|
|||||||
@ -65,6 +65,7 @@ extern ADC_HandleTypeDef hadc1;
|
|||||||
extern ADC_HandleTypeDef hadc3;
|
extern ADC_HandleTypeDef hadc3;
|
||||||
extern TIM_HandleTypeDef htim8;
|
extern TIM_HandleTypeDef htim8;
|
||||||
extern TIM_HandleTypeDef htim10;
|
extern TIM_HandleTypeDef htim10;
|
||||||
|
extern TIM_HandleTypeDef htim11;
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
|
|
||||||
/* USER CODE END EV */
|
/* USER CODE END EV */
|
||||||
@ -240,6 +241,22 @@ void TIM1_UP_TIM10_IRQHandler(void)
|
|||||||
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles TIM1 trigger and commutation interrupts and TIM11 global interrupt.
|
||||||
|
*/
|
||||||
|
void TIM1_TRG_COM_TIM11_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM1_TRG_COM_TIM11_IRQn 0 */
|
||||||
|
TIM11 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
|
||||||
|
TIM4 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
|
||||||
|
TIM11 -> DIER &= ~(1); //disable interrupt
|
||||||
|
/* USER CODE END TIM1_TRG_COM_TIM11_IRQn 0 */
|
||||||
|
HAL_TIM_IRQHandler(&htim11);
|
||||||
|
/* USER CODE BEGIN TIM1_TRG_COM_TIM11_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_TRG_COM_TIM11_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM2 global interrupt.
|
* @brief This function handles TIM2 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user