This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cortex M4 (LPC4370): how do I detect ADC threshold crossing while moving data in a DMA driven double buffer?

Hi to you all,

I'm currently working on a project involving the LPC-Link2 as a eval. board for it's LPC4370 (for a complete explanation see this question).
What I'm trying to do is:

  • Continuously sample external analog signal (using on-board ADCHS)
  • Transfer data to RAM (I'm using a ping-pong buffer: let's call the sub-buffers s[0] and s[1])
  • When a threshold crossing is detected by the ADCHS -> begin data processing

At the moment I managed to be fine with the first 2 bullets, my question is: what is the fastest (and most elegant) way to process data without loosing (too much) samples and whitout interferring with DMA activity?

I tried the following procedure:

  • Use ADCHS interrupt (highest priority) to capture the address at which the DMA is currently pointing (eg. in sub-buffer s[0])
  • Process the data in the DMA ISR (eg. when s[1] is being filled)

BUT, it seems that I'm haviong troubles because of the cortex M4 ISR overhead. A drawing will better explain this:

The * in the image means:

  • ADCHS sampled the threshold-crossing responsible semple in s[1], thus flagging to process s[1]
  • By the time the DMA ISR gets the ADCHS flag s[1] is being filled and the DMA ISR won't process it.

How do I solve this? If anything isn't that clear I will be happy to explain it better.

Any help would be highly appreciated!

Regards,

Andrea

Parents
  • Hi 
    thanks for your replies.
    I must process a signal which is basically a pulse signal. That is: gaussian shape and almost constant lenght:
    This signal is not periodic, but my firmware should be able to process a 30 kcount/s flow.
    Strictly speaking, no: I don't need to perform a continuous processing, I just need the processing to be done before the next peak is completely acquired. And yes, fixed number of samples to be processed. The pulse length is roughly 10 us, so let's say @30 kcount/s that gives a 30% duty cycle. Since I'm acquiring @40 msps I need to process 400 samples in 20us.

    At the momenti I managed to set up the DMA transfer in a ping-pong buffer which is always running. The DMA isr (raised at the end of a sub-buffer transfer) then contains some if statements that check for the ADCHS flag and eventually process the acquired data.

    I understand what you suggest, but am I wrong thinking that triggering the DMA transfer would be too slow? Is this faster that switching between interrupts?
    I know this question may seem rhetorical,  and I'm sorry for this.

    Thanks again!

Reply
  • Hi 
    thanks for your replies.
    I must process a signal which is basically a pulse signal. That is: gaussian shape and almost constant lenght:
    This signal is not periodic, but my firmware should be able to process a 30 kcount/s flow.
    Strictly speaking, no: I don't need to perform a continuous processing, I just need the processing to be done before the next peak is completely acquired. And yes, fixed number of samples to be processed. The pulse length is roughly 10 us, so let's say @30 kcount/s that gives a 30% duty cycle. Since I'm acquiring @40 msps I need to process 400 samples in 20us.

    At the momenti I managed to set up the DMA transfer in a ping-pong buffer which is always running. The DMA isr (raised at the end of a sub-buffer transfer) then contains some if statements that check for the ADCHS flag and eventually process the acquired data.

    I understand what you suggest, but am I wrong thinking that triggering the DMA transfer would be too slow? Is this faster that switching between interrupts?
    I know this question may seem rhetorical,  and I'm sorry for this.

    Thanks again!

Children