arduino-libraries / Arduino_AdvancedAnalog

Advanced Analog Library
GNU Lesser General Public License v2.1
7 stars 5 forks source link

Pins from A8 to A11 cannot be used on Arduino Giga R1 #81

Open mzap-bit opened 2 days ago

mzap-bit commented 2 days ago

Hello guys,

I am struggling to acquire a signal using A8,A9,A10, A11 pins of Arduino Giga R1.

Here's the modified example code I am using:

#include <Arduino_AdvancedAnalog.h>

AdvancedADC adc(A8.get()); // I must use this method to avoid compiler error
// AdvancedADC adc(PC_2C); // this doesn't wok as well I assume AdvancedAnalog relies on pins_arduino.h definitions (where the PureAnalogPins are not defined)
uint64_t last_millis = 0;

void setup() {
    Serial.begin(9600);

    // Resolution, sample rate, number of samples per channel, queue depth.
    if (!adc.begin(AN_RESOLUTION_16, 16000, 32, 128)) {
        Serial.println("Failed to start analog acquisition!");
        while (1);
    }
}

void loop() {
    if (adc.available()) {
        SampleBuffer buf = adc.read();
        // Process the buffer.
        if ((millis() - last_millis) > 20) {
          Serial.println(buf[0]);   // Sample from first channel
          Serial.println(buf[1]);   // Sample from second channel
          last_millis = millis();
        }
        // Release the buffer to return it to the pool.
        buf.release();
    }
}

The code compiles, but the serial values are showing values as if the pin is floating (despite I have placed a 1k resistor to 3.3V).

leonardocavagnis commented 1 day ago

Hi @mzap-bit,

Currently, the library does not support PureAnalogPin on the Arduino GIGA R1 (A8, A9, A10, and A11). We will address this issue in the next release.

Thank you for reporting it.

mzap-bit commented 1 day ago

Hi @leonardocavagnis ,

You're welcome! Thank you for your great work! :)

Just a small hint for the API doc: currently it is mentioned the Pins from A8 to A11 are actually supported, I've spent some time wondering what was wrong with my code trusting this info! A slight update might help other users!