How to retrive buffer index in ADC error callback?

Discussions and support about ChibiOS/RT, the free embedded RTOS.
maxpav
Posts: 3
Joined: Tue Oct 19, 2021 8:24 am
Has thanked: 1 time

How to retrive buffer index in ADC error callback?

Postby maxpav » Sun Aug 06, 2023 5:40 pm

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

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

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

Postby Giovanni » Sun Aug 06, 2023 6:58 pm

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


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 7 guests