SPI with DMA , erratic behavior on ADC1

Post here first, or if you can't find a relevant section!
Post Reply
alexandros
Posts: 42
Joined: Mon Oct 02, 2017 6:51 pm

SPI with DMA , erratic behavior on ADC1

Post by alexandros » Sat Nov 18, 2017 10:30 pm

Hi there ,
I am reading ADC1 values from pin PA1 just fine ,,,

Code: Select all


    pinMode(PINPoti__, INPUT_ANALOG);
    .......
    dev2 = PIN_MAP[PINPoti__].adc_device;
    PINPoti = PIN_MAP[PINPoti__].adc_channel;
    adc_set_sample_rate(dev2, ADC_SMPR_13_5);
    adc_reg_map *regs2 = dev2->regs;
    adc_set_reg_seqlen(dev2, 1);
    regs2->SQR3 = PINPoti;
    adc_calibrate(dev2);
    .....
  value=  adc_read(dev, PINPoti)
    .
Until

I start a parallel job SPI with DMA transfer. when the Transfer begin , i get 20% false increase value in PINPoti__ !! when the transfer ends , the readings are getting back to normal!! ,
Last edited by alexandros on Sat Nov 18, 2017 11:03 pm, edited 1 time in total.

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: SP2 with DMA , erratic behavior on ADC1

Post by stevestrong » Sat Nov 18, 2017 10:59 pm

You probably mean SPI, right?
I have the same experience, the digital noise influnces the ADC readings a lot.
That is why the latest original maple mini boards had separated Vcc and GND for analog and digital.
The china clones don't have them.

The workaround i did was reading the analog input with one blue pill supplied from batteries, and sending the readings to a second blue pill after the ADC sampling finished. In this way I achieved +/-1 bit deviation.

alexandros
Posts: 42
Joined: Mon Oct 02, 2017 6:51 pm

Re: SPI with DMA , erratic behavior on ADC1

Post by alexandros » Sat Nov 18, 2017 11:06 pm

YEs SPI i edited the title.

OH Man That is bad news ! there is no other way programmatically ? right?

i tryied to read the analog value with the classic way analogRead(PINPoti__) but i got the same results.

alexandros
Posts: 42
Joined: Mon Oct 02, 2017 6:51 pm

Re: SPI with DMA , erratic behavior on ADC1

Post by alexandros » Sat Nov 18, 2017 11:36 pm

There is also something that i didnt said before.
I am reading ADC0 values pin PA0 , and the results there are intact , so there must be something wrong with ADC1

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: SPI with DMA , erratic behavior on ADC1

Post by stevestrong » Sun Nov 19, 2017 7:30 am

In my case both ADC0 and ADC1 readings were affected.

Post Reply