[mausi_mick – Wed Mar 28, 2018 12:51 pm] –
Not solved is the triggering.
A really cheap way of doing triggering is to use the ADC’s analog watchdog.
For a rising trigger set the low threshold (LTR) to zero and the high threshold (HTR) to the value you want to trigger on (for a falling trigger, set HTR to 4095 and LTR to the trigger value). You can check the AWD flag in the ADC status register (which your code already loads when checking if a conversion is complete) to see if a trigger has occurred. You can even get it to generate an interrupt if you decide to change to capturing samples using DMA in the future.
Keep in mind you’ll have to scale the trigger level you program the AWD registers with to match your OPAMP gain.
It might be worth worth considering moving to a DMA in any case. It actually makes things easier and you’ll be able to avoid the need to write assembler code. Let me know if you want to know how I go about it for my F3 based oscilloscope project.