It seems that using the comparators with interrupts on the stm32f373 series with HAL drivers blocks the program in infinite loop.
- October 17, 2018
- 7 replies
- 2897 views
I attach the full code as a file and the relevant part here - for the evaluation board STM32373C-EVAL in which the red LED blinks a few times until the comparator is activated and blocks the execution.
Is there a workaround to make the comparator work with interrupts and the HAL library?
Thanks!
/* USER CODE BEGIN 2 */
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 1000);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
int lTick = HAL_GetTick();
int count = 0;
while (1)
{
int tick = HAL_GetTick();
if(tick - lTick >= 500) {
lTick = tick;
count ++;
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);
if(count == 6) {
// will block the main program
HAL_COMP_Start_IT(&hcomp1);
}
}
/* USER CODE END WHILE */
