• AVR Freaks

A/D, cant identify which sample came from which channel on dsPIC33EP512GP806

Author
theozo
Starting Member
  • Total Posts : 42
  • Reward points : 0
  • Joined: 2015/03/15 02:30:18
  • Location: Hungary
  • Status: offline
2019/10/23 14:16:58 (permalink)
0

A/D, cant identify which sample came from which channel on dsPIC33EP512GP806

Hi!
 
I am using a dsPIC33EP512GP806, my code samples 10 channels on 10bit mode, 6 has to be at the highest possible frequency 4 of them can be sampled less regularly. So 6 channels have been sampled every time while the other four has been sampled every second time. To do that I am using simultaneous sampling for 4 channels modules and also use the alternate input sample mode on 2 A/D modules.
The math works 6*1+4*1/2 = 8. So I will get samples from all channels by the second run. I am using the A/D dedicated buffers to collect the samples. The problem is that there is no indicator (or at least I or I can't find) in the ADCON registers that shows which alternative setup is in use, so... problem.
If I keep track how many times I collected the samples then I will know which sample belongs to which channels. Until, there is an error. Once I loose track, there is no way to figure it out. Until the A/D get restarted. Not helpful for a motor drive... :)

There is a solution by the use of DMA channels with scattered/gathered addressing mode and ping-pong buffering mode. Luckily DMA has indicator for ping-pong buffer usage. The address of the sample determines which channel it came from. And just to be sure after reading the value in the buffer should be replaced by an invalid one. For example it can be 1024 or greater or negative. In this case the software can decide if the sample has or hasn't been updated.

I just don't like the complexity of this solution.
I wonder if there is a simple solution?

Best regards

theo
#1

2 Replies Related Threads

    al_bin
    Super Member
    • Total Posts : 171
    • Reward points : 0
    • Joined: 2011/02/11 06:28:47
    • Location: 0
    • Status: online
    Re: A/D, cant identify which sample came from which channel on dsPIC33EP512GP806 2019/10/23 22:53:50 (permalink)
    0
    Maybe use ADCBUF0..ADCBUF7 and generate interrupt after completion of every 8th conversion is a solution?
    Albert
    #2
    theozo
    Starting Member
    • Total Posts : 42
    • Reward points : 0
    • Joined: 2015/03/15 02:30:18
    • Location: Hungary
    • Status: offline
    Re: A/D, cant identify which sample came from which channel on dsPIC33EP512GP806 2019/10/25 11:40:03 (permalink)
    0
    Yes it is a solution! Thank you.
    I feel like a dummy now. Some short in the brain...
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5