user61410: I'm currently using the STM32F1xx boards from http://dan.drown.org/stm32duino/package_STM32duino_index.json
To program my blue pill but I can’t find how to write the interrupt for the ADC. I’ve set the registers to output an interrupt when it finishes but I can’t find how to write the code for the interrupt.
I’ve tried the ”ISR(ADC_vect)” function which works for arduino, but the compiler is complaining that ”ISR” is not recognized. I’ve tried to look for the documentation for the STM32duino, but the little I could find didn’t even mention the ADC or any interrupt routines. I’ve searched though the STM32duino forum without any luck. If anyone knows how to solve this or where to find information about interrupt code for the STM32 boards I would be very happy :)

user61410: I couldn't find the function being called directly, but there's a good example explaining how to attach interrupts to the ADC which works well: https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/STM32ADC/examples/SingleConversionInterrupt/SingleConversionInterrupt.ino
If anyone knows the actual function being called directly that would be great to add on here, but until then this example does what I need and will hopefully help others having the same problem.

user11763: As you already found, the function to override is __irq_adc() defined weakly here and bound to the interrupt vector table here.
If you've defined it and it's not working, it's probably because you got rid of the attachInterrupt() call entirely, which does more than just assign an interrupt handler; it also enables the interrupt for that ADC. So:
myADC.calibrate();
myADC.setSampleRate(ADC_SMPR_1_5);
adc_enable_irq(ADC1, ADC_EOC);
myADC.setPins(&pin, 1);

extern "C" void __irq_adc() {
// handle the interrupt
// make sure to check statuses and clear flags as shown in the default handler
}

Not sure if the extern "C" will be needed, probably will be, you'll have to check and find out.

61410: <p>I'm currently using the STM32F1xx boards from <a href="http://dan.drown.org/stm32duino/package_STM32duino_index.json" rel="nofollow noreferrer">http://dan.drown.org/stm32duino/package_STM32duino_index.json</a>
To program my blue pill but I can’t find how to write the interrupt for the ADC. I’ve set the registers to output an interrupt when it finishes but I can’t find how to write the code for the interrupt.</p>
<p>I’ve tried the ”ISR(ADC_vect)” function which works for arduino, but the compiler is complaining that ”ISR” is not recognized. I’ve tried to look for the documentation for the STM32duino, but the little I could find didn’t even mention the ADC or any interrupt routines. I’ve searched though the STM32duino forum without any luck. If anyone knows how to solve this or where to find information about interrupt code for the STM32 boards I would be very happy :)</p>
 61410: <p>I couldn't find the function being called directly, but there's a good example explaining how to attach interrupts to the ADC which works well: <a href="https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/STM32ADC/examples/SingleConversionInterrupt/SingleConversionInterrupt.ino" rel="nofollow noreferrer">https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/libraries/STM32ADC/examples/SingleConversionInterrupt/SingleConversionInterrupt.ino</a></p>
<p>If anyone knows the actual function being called directly that would be great to add on here, but until then this example does what I need and will hopefully help others having the same problem.</p>
 11763: <p>As you already found, the function to override is <code>__irq_adc()</code> defined weakly <a href="https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/cores/maple/libmaple/adc_f1.c" rel="nofollow noreferrer">here</a> and bound to the interrupt vector table <a href="https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F1/cores/maple/libmaple/stm32f1/performance/vector_table.S" rel="nofollow noreferrer">here</a>.</p>
<p>If you've defined it and it's not working, it's probably because you got rid of the <code>attachInterrupt()</code> call entirely, which does more than just assign an interrupt handler; it also enables the interrupt for that ADC. So:</p>
<pre><code>myADC.calibrate();
myADC.setSampleRate(ADC_SMPR_1_5);
adc_enable_irq(ADC1, ADC_EOC);
myADC.setPins(&amp;pin, 1);

extern &quot;C&quot; void __irq_adc() {
// handle the interrupt
// make sure to check statuses and clear flags as shown in the default handler
}
</code></pre>
<p>Not sure if the <code>extern &quot;C&quot;</code> will be needed, probably will be, you'll have to check and find out.</p>
