Interrupt driven comparator
- This topic has 1 reply, 1 voice, and was last updated 7 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Tagged: xdot comparator
I’m not sure if this is the proper forum to ask this question, but it might be libxDot-mbed5 related. I want to set up an interrupt driven comparator. 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? Is it feasible?
Is it indeed the case that COMP2 is not available (it is not mentioned in the MTXDOT Developer Guide)?
Okay, it was a bit complicated and not an xDot specific issue: https://developer.mbed.org/questions/77516/Interrupt-driven-comparator/.
As for COMP2, that is not available for the xDot as this comparator can’t be routed to pins which are available for us. Luckily, COMP1 will do the job I need to do.
Cheers, Mark