Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIGA R1 - analogRead(A12) returns A8 value #758

Closed
megacct opened this issue Nov 12, 2023 · 6 comments · Fixed by #784
Closed

GIGA R1 - analogRead(A12) returns A8 value #758

megacct opened this issue Nov 12, 2023 · 6 comments · Fixed by #784
Assignees
Labels
bug Something isn't working GIGA

Comments

@megacct
Copy link

megacct commented Nov 12, 2023

and analogRead(A13) returns A9 value. However, using Adafruit advancedAnalog library the correct values for A12 and A13 are returned

@facchinm
Copy link
Member

Mmmmh no, I retested just to make sure and it works as intended (reads A13/DAC1 value when analogRead(A13) is called).
Are you sure you are not using digitalRead() ? Because pins from A8 to A11 are analog only and get skipped in the count when using as digital https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/GIGA/pins_arduino.h#L54-L55 since they can't be used as digital pins.

@megacct
Copy link
Author

megacct commented Nov 13, 2023

Thanks for replying. I've made some progress narrowing this down. Board is connected via usb and no external components.

Using this code:

void setup() {
  Serial.begin(115200);
  while (!Serial) {;}
}
void loop() {
  int sensorValue8 = analogRead(A8);
  int sensorValue9 = analogRead(A9);
  int sensorValue12 = analogRead(A12);
  int sensorValue13 = analogRead(A13);

  Serial.print(" A8: ");
  Serial.print(sensorValue8);
  Serial.print(" A9: ");
  Serial.print(sensorValue9);
  Serial.print(" A12: ");
  Serial.print(sensorValue12);
  Serial.print(" A13: ");
  Serial.println(sensorValue13);
  delay(1000);  
}

With nothing connected to pins I get:
A8: 77 A9: 59 A12: 78 A13: 71
A8: 75 A9: 59 A12: 78 A13: 71
A8: 75 A9: 59 A12: 77 A13: 70
A8: 74 A9: 57 A12: 77 A13: 69
A8: 73 A9: 55 A12: 77 A13: 69
A8: 71 A9: 55 A12: 77 A13: 63
A8: 71 A9: 54 A12: 75 A13: 63
A8: 71 A9: 55 A12: 75 A13: 69
A8: 73 A9: 55 A12: 76 A13: 63
A8: 75 A9: 59 A12: 77 A13: 71

With th 3.3v pin connected to A12 or A13, no change.

With th 3.3v pin connected to A8 I get this:
A8: 1023 A9: 199 A12: 1023 A13: 238
A8: 1023 A9: 201 A12: 1023 A13: 239
A8: 1023 A9: 201 A12: 1023 A13: 239
A8: 1023 A9: 199 A12: 1023 A13: 239
A8: 1023 A9: 197 A12: 1023 A13: 237
A8: 1023 A9: 191 A12: 1023 A13: 236
A8: 1023 A9: 189 A12: 1023 A13: 234
A8: 1023 A9: 183 A12: 1023 A13: 232

With 3.3v on A9 I get this:
A8: 73 A9: 1023 A12: 191 A13: 1023
A8: 70 A9: 1023 A12: 190 A13: 1023
A8: 69 A9: 1023 A12: 190 A13: 1023
A8: 73 A9: 1023 A12: 190 A13: 1023
A8: 77 A9: 1023 A12: 191 A13: 1023
A8: 85 A9: 1023 A12: 191 A13: 1023

IF I comment out the analogRead and prints for A8 and A9:

void setup() {
  Serial.begin(115200);
  while (!Serial) {;}
}
void loop() {
//  int sensorValue8 = analogRead(A8);
//  int sensorValue9 = analogRead(A9);
  int sensorValue12 = analogRead(A12);
  int sensorValue13 = analogRead(A13);

//  Serial.print(" A8: ");
//  Serial.print(sensorValue8);
//  Serial.print(" A9: ");
//  Serial.print(sensorValue9);

  Serial.print(" A12: ");
  Serial.print(sensorValue12);
  Serial.print(" A13: ");
  Serial.println(sensorValue13);
  delay(1000);     
}

and then apply 3.3v to A12 I get this:
A12: 1023 A13: 283
A12: 1023 A13: 251
A12: 1023 A13: 217
A12: 1023 A13: 200
A12: 1023 A13: 223
A12: 1023 A13: 255

3.3v on A13 give this:
A12: 195 A13: 1023
A12: 175 A13: 1023
A12: 171 A13: 1023
A12: 190 A13: 1023
A12: 209 A13: 1023

And 3.3v on A8 or A9 has no effect.

So it only seems to be a problem when reading A8/A9.

@facchinm
Copy link
Member

Got it, I've been able to replicate.
@Rocketct can you take a look?

@facchinm facchinm added bug Something isn't working GIGA and removed waiting for feedback labels Nov 13, 2023
@Rocketct
Copy link
Contributor

sure @facchinm

@Rocketct
Copy link
Contributor

Rocketct commented Dec 1, 2023

Ciao @megacct this PR should fix the issue

@white-ar
Copy link

white-ar commented Jul 25, 2024

Hello, I've just come across the issue with a Giga R1. Upgrading to V 4.1.5 of the board library temporarily fixed the issue, however it has returned. Seems to only occur when compiling for the M4 co-processor core. Here is the very simple sketch:

@facchinm @Rocketct is there a way of addressing A9 using MBED calls? (as a work around). Thank you.

#include "Arduino.h"
#include "RPC.h"

#define SERVO_POT_1     A9

void setup() {
  // put your setup code here, to run once:
  RPC.begin();

  analogReadResolution(16); //GIGA has 16 bit ADC  (0-65535)  

}

void loop() {
  // put your main code here, to run repeatedly:

int temp = analogRead(SERVO_POT_1);



}

Error message:
C:...\AppData\Local\Temp\arduino\sketches\D2129B132D44D2F5F57EC30CA80C2E2B\sketch\sketch_jul25a.ino.cpp.o: In function loop': C:\...\AppData\Local\Temp\.arduinoIDE-unsaved2024625-43476-ja9cee.pq8d\sketch_jul25a/sketch_jul25a.ino:20: undefined reference to A9'
C:...\AppData\Local\Temp.arduinoIDE-unsaved2024625-43476-ja9cee.pq8d\sketch_jul25a/sketch_jul25a.ino:20: undefined reference to `analogRead(PureAnalogPin)'
collect2.exe: error: ld returned 1 exit status

Using library RPC at version 1.0 in folder: C:...\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.5\libraries\RPC
Using library rpclib at version 1.0.0 in folder: C:...\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.5\libraries\rpclib
Using library openamp at version 1.0 in folder: C:...\AppData\Local\Arduino15\packages\arduino\hardware\mbed_giga\4.1.5\libraries\openamp_arduino
exit status 1

Compilation error: exit status 1

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GIGA
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants