Page 1 of 1

How to retrive buffer index in ADC error callback?

Posted: Sun Aug 06, 2023 5:40 pm
by maxpav
Hello,

I am using an ADC in circular mode, and I set an AWD interrupt in order to detect when the signal has fallen below a given value. My error callback is called correctly.
What I want to do now, in the error callback, is to retrieve the index of the buffer when the interrupt occurred, i.e. to determine where was the last sample written in the buffer just before the interrupt stopped the conversion. I cannot find any information about this in the documentation.
Would this be possible in a direct manner? Otherwise do you see any workarounds?

Thank you in advance

Re: How to retrive buffer index in ADC error callback?

Posted: Sun Aug 06, 2023 6:58 pm
by Giovanni
Hi,

This use case is not supported by the ADC API. It would be possible to modify the driver ISR to read the DMA memory pointer value or the counter register, it has to be done just before the DMA channel is stopped.

The UART driver does something similar if I remember well.

Giovanni