Skip to content

Digital Pin Numbering off for D76-D83, D84-D85, and D93-D94 #7

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

Closed
mjs513 opened this issue Dec 9, 2024 · 2 comments
Closed

Digital Pin Numbering off for D76-D83, D84-D85, and D93-D94 #7

mjs513 opened this issue Dec 9, 2024 · 2 comments

Comments

@mjs513
Copy link

mjs513 commented Dec 9, 2024

Using the Giga full pinout diagram and a test setup
Image

and sketch modified from a @KurtE sketch

int current_pin = 13;
int next_pin_number = 0;
#define DBGSerial Serial
void setup() {
    // Blink any pin.  Note: I put pin 13 as input to see if we can
  // jumper to it to see if we can find the pin...
  while (!Serial && millis() < 5000);
  DBGSerial.begin(115200);
  delay (250);
  DBGSerial.println("Find Pin by blinking");
  DBGSerial.println("Enter pin number to blink"); 
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (DBGSerial.available()) {
    int ch;
    while ((ch = DBGSerial.read()) != -1) {
      if ((ch >='0') && (ch <= '9')) {
        next_pin_number = next_pin_number * 10 + (ch-'0');
      } else {
        if (next_pin_number != 0) {
          digitalWrite(current_pin, LOW); // turn the previous pin to low...
          current_pin = next_pin_number;
          pinMode(current_pin, OUTPUT);
          if (current_pin != 13)
            pinMode(13, INPUT);
          digitalWrite(current_pin, HIGH);
          next_pin_number = 0;  // setup to enter next pin
          Serial.print("Now Blinking pin:"); Serial.println(current_pin);
        }
      }
    }
  } else {
    digitalWrite(current_pin, !digitalRead(current_pin));
    delay(250);
  }  
}

D0-D60 ring out per the giga pinouts.

D76-D83 (A0 to A7) ring out to D78-D85 (off by 2)
D84-D85 ringout to D90 and D91
D93-D94 ringout to D92 and D93.

Think numbering is off somewhere.

facchinm added a commit to facchinm/ArduinoCore-zephyr that referenced this issue Dec 18, 2024
facchinm added a commit to facchinm/ArduinoCore-zephyr that referenced this issue Dec 18, 2024
facchinm added a commit to facchinm/ArduinoCore-zephyr that referenced this issue Dec 18, 2024
@KurtE
Copy link

KurtE commented Dec 21, 2024

Here is a modified version of my (and defragster)HiLow test... probably only does low right... Need to check, don't remember if giga support pull up and pull down on IO pins.

This sketch is also pushed up now into my giga stuff repository.

//#ifdef ESP_PLATFORM
// BUGBUG UNOR4 boards do not support PULL_DOWN

#define digitalWriteFast digitalWrite
#define digitalReadFast digitalRead

#define INTERRUPT_HELPER(n, p, i) 1
#define NUM_DIGITAL_PINS                                                        \
  DT_FOREACH_PROP_ELEM_SEP(DT_PATH(zephyr_user), digital_pin_gpios,            \
                           INTERRUPT_HELPER, (+))

extern void allPinTest();
extern void testForShorts();

//#endif
void setup() {
  Serial.begin(115200);
  while (!Serial && millis() < 10000 );
  //Serial.println("Compile Time:: " __FILE__ " " __DATE__ " " __TIME__);
  Serial.print("Num Digital Pins: ");
  Serial.println(NUM_DIGITAL_PINS, DEC);
  Serial.flush();

  testForShorts();
  
}

void loop() {
    allPinTest( );
}

uint32_t pinLast[NUM_DIGITAL_PINS];
void allPinTest() {
  uint32_t ii;
  Serial.print("PULLUP Start Vals:\n  ");
  Serial.print("PULLUP :: TEST to GND\n  ");
  for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
    pinMode( ii, INPUT_PULLUP );
    delayMicroseconds( 5 );
    pinLast[ii] = digitalReadFast( ii );
    if (!pinLast[ii]) {
      Serial.print("\nd#=");
      Serial.print( ii );
      Serial.print( " val=" );
    }
    Serial.print( pinLast[ii] );
    Serial.print(',');
  }
  Serial.println();
  Serial.println();
  while ( 1 ) {
    uint32_t jj, dd = 0, cc = 0, ee=4;
    cc = 0;
    for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
      jj = digitalReadFast( ii );
      if ( jj != pinLast[ii] ) {
        dd = 1;
        cc++;
        pinLast[ii] = jj;
        Serial.print("d#=");
        Serial.print( ii );
        if ( pinLast[ii] ) Serial.print( "\t" );
        Serial.print( " val=" );
        Serial.print( pinLast[ii] );
        Serial.print(',');
      }
      if ( cc > 1 && ee ) {
        Serial.println(">>> MULTI CHANGE !!");
        ee--;
      }
#if 0
      if ( Serial.available() ) {
        while ( Serial.available() ) Serial.read();
        if ( 0 == SET ) {
          SET = 1;
          Serial.print("PULLUP :: TEST TO GND\n  ");
        }
        else {
          SET = 0;
          Serial.print("PULLDOWN :: TEST to 3.3V\n  ");
        }
        for ( ii = 0; ii < NUM_DIGITAL_PINS; ii++) {
          if ( 0 == SET )
            pinMode( ii, INPUT_PULLDOWN );
          else
            pinMode( ii, INPUT_PULLUP );
          delayMicroseconds( 20 );
          pinLast[ii] = digitalReadFast( ii );
          if (SET != pinLast[ii]) {
            Serial.print("d#=");
            Serial.print( ii );
            Serial.print( " val=" );
            Serial.println( pinLast[ii] );
          }
        }
      }
#endif      
    }
    if ( dd ) {
      dd = 0;
      Serial.println();
      delay( 50 );
    }
  }
}

void testForShorts() {
  uint32_t ii;
  Serial.print("Quick Test for Shorts to adjacent pin");
#if 1
  Serial.println("UNOR4 does not support INPUT_PULLDOWN");
#else
  Serial.println("First pull pins down and see if the next one follows");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLDOWN );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, HIGH);
    delayMicroseconds( 5 );
    if (digitalRead(ii+1)) {
      Serial.print(ii,DEC);
      Serial.print(":");
      Serial.println(ii+1, DEC);
    }
  }
#endif  
  Serial.println("\n Now try Pull up and see if setting low follow");
  for ( ii = 0; ii < NUM_DIGITAL_PINS-1; ii++) {
    pinMode( ii+1, INPUT_PULLUP );
    pinMode( ii, OUTPUT);
    digitalWrite(ii, LOW);
    delayMicroseconds( 5 );
    if (!digitalRead(ii+1)) {
      Serial.print(ii,DEC);
      Serial.print(":");
      Serial.println(ii+1, DEC);
    }
  }
  Serial.println();  
}

Note I am trying this on Ubuntu with the code synced up to PR #17

I believe that PR fixes several of these issues.
I have not fully rung it out yet:
But as I mentioned on comments on PR:
SCL1/SDA1 are ringing out wrong as compared to full pinout.
The pinout shows pins 101/102, but they ring out as 95, 96.
This is true for both the pins on the main shield area (upper right on P1),
as well as the Camera area Page 2

I believe the digital-pin-gpios table in the overlay is missing these pins, that
are defined within the MBED version:

// WIFI CONTROL
  { PI_8,         NULL, NULL, NULL },    // D95  WIFI HOST WAKE
  { PB_10,        NULL, NULL, NULL },    // D96  WIFI ON

  // BLE CONTROL
  { PH_7,         NULL, NULL, NULL },    // D97  BLE DEVICE WAKE
  { PG_3,         NULL, NULL, NULL },    // D98  BLE HOST WAKE
  { PA_10,        NULL, NULL, NULL },    // D99  BLE ON

  // BOOT
  { PC_13,        NULL, NULL, NULL },    // D100 BOOT0

Which makes sense as that would map 95->101 which is what we expected.

@mjs513
Copy link
Author

mjs513 commented Dec 22, 2024

@facchinm

Feeling better so finally synched up with your PR changes as of today and reran blinkanypin sketch. Pin numbering for D76-D83 and D93/D94 now working so looks like that part is fixed.

However with that said pins 101/102 (SCL1 and SDA1) are still problems as @KurtE pointed out, they ring out to be D94/D95 per above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants