2020-04-16 10:53 PM
comparator does not interrupt
This function handles TIM6, DAC1 and LPTIM1 interrupts (LPTIM1 interrupt through EXTI line 29).
LL_EXTI_LINE_17 ?
17 ? 29 ?
@file : main.c
LL_TIM_GenerateEvent_CC1(TIM6);
LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_17);
LL_EXTI_EnableEvent_0_31(LL_EXTI_LINE_17);
@file : main.c
/**
* @brief COMP1 Initialization Function
* @param None
* @retval None
*/
static void MX_COMP1_Init(void)
{
/* USER CODE BEGIN COMP1_Init 0 */
/* USER CODE END COMP1_Init 0 */
LL_COMP_InitTypeDef COMP_InitStruct = {0};
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOC);
/**COMP1 GPIO Configuration
PA6 ------> COMP1_OUT
PC5 ------> COMP1_INP
*/
GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN COMP1_Init 1 */
/* USER CODE END COMP1_Init 1 */
COMP_InitStruct.InputPlus = LL_COMP_INPUT_PLUS_IO1;
COMP_InitStruct.InputMinus = LL_COMP_INPUT_MINUS_DAC1_CH1;
COMP_InitStruct.InputHysteresis = LL_COMP_HYSTERESIS_NONE;
COMP_InitStruct.OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
COMP_InitStruct.OutputBlankingSource = LL_COMP_BLANKINGSRC_NONE;
LL_COMP_Init(COMP1, &COMP_InitStruct);
LL_COMP_SetPowerMode(COMP1, LL_COMP_POWERMODE_HIGHSPEED);
LL_COMP_SetCommonWindowMode(__LL_COMP_COMMON_INSTANCE(COMP1), LL_COMP_WINDOWMODE_DISABLE);
LL_COMP_SetCommonWindowOutput(__LL_COMP_COMMON_INSTANCE(COMP1), LL_COMP_WINDOWOUTPUT_EACH_COMP);
/* Wait loop initialization and execution */
/* Note: Variable divided by 2 to compensate partially CPU processing cycles */
__IO uint32_t wait_loop_index = 0;
wait_loop_index = (LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US * (SystemCoreClock / (1000000 * 2)));
while(wait_loop_index != 0)
{
wait_loop_index--;
}
LL_EXTI_DisableEvent_0_31(LL_EXTI_LINE_17);
LL_EXTI_DisableIT_0_31(LL_EXTI_LINE_17);
/* USER CODE BEGIN COMP1_Init 2 */
/* USER CODE END COMP1_Init 2 */
}
@file stm32g0xx_it.h
/**
* @brief This function handles TIM6, DAC1 and LPTIM1 interrupts (LPTIM1 interrupt through EXTI line 29).
*/
void TIM6_DAC_LPTIM1_IRQHandler(void)
{
/* USER CODE BEGIN TIM6_DAC_LPTIM1_IRQn 0 */
if(LL_TIM_IsActiveFlag_CC1(TIM6)==1)
{
// LL_TIM_ClearFlag_UPDATE(TIM6);
// LL_TIM_ClearFlag_CC1OVR(TIM6);
LL_TIM_ClearFlag_CC1(TIM6);
/* LED toggling */
LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
}
/* USER CODE END TIM6_DAC_LPTIM1_IRQn 0 */
/* USER CODE BEGIN TIM6_DAC_LPTIM1_IRQn 1 */
/* USER CODE END TIM6_DAC_LPTIM1_IRQn 1 */
}
/**
* @brief This function handles ADC1, COMP1 and COMP2 interrupts (COMP interrupts through EXTI lines 17 and 18).
*/
void ADC1_COMP_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_COMP_IRQn 0 */
/* LED toggling */
LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
/* USER CODE END ADC1_COMP_IRQn 0 */
/* USER CODE BEGIN ADC1_COMP_IRQn 1 */
/* USER CODE END ADC1_COMP_IRQn 1 */
}
2020-04-22 02:35 AM
Hello @Ecift.1
Could you please share your ioc file?
Thanks,
Khouloud