Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 8 months ago.
Interrupt driven comparator
I want to set up an interrupt driven comparator on a xDot (STM32L151CC). This is what I basically tried (inspired by https://github.com/bjornfor/stm32-test/tree/master/STM32L1xx_StdPeriph_Lib_V1.1.1/Project/STM32L1xx_StdPeriph_Examples/COMP/COMP_Interrupt):
COMP_HandleTypeDef Comp1Handle; DigitalOut myled(LED1); AnalogIn ain(PB_0); void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) { myled = myled ? 0 : 1; } int main() { Comp1Handle.Instance = COMP1; Comp1Handle.Init.NonInvertingInput = COMP_NONINVERTINGINPUT_PB0; Comp1Handle.Init.NonInvertingInputPull = COMP_NONINVERTINGINPUT_NOPULL; Comp1Handle.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING_FALLING; HAL_COMP_Init(&Comp1Handle); HAL_COMP_Start_IT(&Comp1Handle); while ( true ) { wait(1); } }
But the interrupt handler is never called. What should I do to get this running?
Many thanks,
Mark
Well, I think I figured it out... For a comparator on PB0 which generates interrupts:
Especially NVIC_SetVector(...) was not obvious to me. I expected that the HAL driver would call HAL_COMP_TriggerCallback(), but that is not the case.
posted by Mark Ruys 23 Mar 2017