Pedvide ADC Library what is "pabdma"?

Status
Not open for further replies.

Maximiljan

Active member
Hello All,

probably a dumb question, but what on earth is "pabdma" in the Pedvide ADC library?

An example of where this comes up is in the ADC_dma example code:

[ CODE] void ProcessAnalogData(AnalogBufferDMA *pabdma, int8_t adc_num) {
uint32_t sum_values = 0;
uint16_t min_val = 0xffff;
uint16_t max_val = 0; [ /CODE]

The code works really well but don't understand what this actually is. :/
 
It is an object of the type: AnalogBufferDMA ...

It was an object that I created when a few of us were trying to get the ADC library to work on the Teensy T4. I found the previous existing dma ring buffer object did not work. Both do to issues with the settings of the underlying DMA code, as well as it was sort of obvious it was never completed as none of the other methods were implemented...

There may be simpler ways to it, but it uses two DMA settings objects, which are chained to each other and setup to each interrupt when their buffer is filled... Again you might be able to do it with just one DMA buffer, but I kept running into issues where only one half of it was used and other times it would write into strange places in memory... So I set it up the way I knew worked.

Again I did it as a test case, and was kept when the owner of the library (@pedvide) merged everything in.
 
It is an object of the type: AnalogBufferDMA ...

It was an object that I created when a few of us were trying to get the ADC library to work on the Teensy T4. I found the previous existing dma ring buffer object did not work. Both do to issues with the settings of the underlying DMA code, as well as it was sort of obvious it was never completed as none of the other methods were implemented...

There may be simpler ways to it, but it uses two DMA settings objects, which are chained to each other and setup to each interrupt when their buffer is filled... Again you might be able to do it with just one DMA buffer, but I kept running into issues where only one half of it was used and other times it would write into strange places in memory... So I set it up the way I knew worked.

Again I did it as a test case, and was kept when the owner of the library (@pedvide) merged everything in.

Thank you for that! Amazing work

Thank you! Amazing work by the way, I am in way over my head with this level of programming but T4 and this library has amazing potential I think so will keep hammering away until I fully understand it.
 
Hi KurtE,

getting to grips with the ADC library slowly, but when using the ADC_timer_DMA_oneshot example code, how can I retrieve the data written to the buffer?

The output from the example is a minimum, maximum, average and RMS ADC values. However how can I see the raw data one which these values are based?

Thanks in advance.
 
You can extract the data from the same place that computes the min/max...
Code:
const uint32_t buffer_size = 1600;
DMAMEM static volatile uint16_t __attribute__((aligned(32))) dma_adc_buff1[buffer_size];
DMAMEM static volatile uint16_t __attribute__((aligned(32))) dma_adc_buff2[buffer_size];
AnalogBufferDMA abdma1(dma_adc_buff1, buffer_size, dma_adc_buff2, buffer_size);
That is the object is created with two buffers you pass in.

The example code is setup that the ISR when a DMA chain completes it sets flags, which we check in the main line.
The example calls a function processAnalogData with a pointer to the buffer that has all of the analog read data. What you do with that data is up to you.

My example computed min, max and an RMS like value as that is sort of the one case I used ADC before which was to try to compute an amperage on some pins (loops around AC power circuits), to maybe know when my wells were running... A project I never complete. As I don't worry about it when the water system is working :D
 
Thanks Kurt, OK that makes sense. Really appreciate all the feedback.

Glad that your water system is working but also glad that it forced you two write this code :p
 
Status
Not open for further replies.
Back
Top