You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • In source, this is clearly done:

    
    JsVarFloat jshPinAnalog(Pin pin) {
      if (pin >= JSH_PIN_COUNT /* inc PIN_UNDEFINED */ || pinInfo[pin].analog==JSH_ANALOG_NONE) {
        jshPrintCapablePins(pin, "Analog Input", 0,0,0,0, true);
        return 0;
      }
      **jshSetPinStateIsManual(pin, false);
      jshPinSetState(pin, JSHPINSTATE_ADC_IN);**
    
      return jshAnalogRead(pinInfo[pin].analog, false) / (JsVarFloat)65535;
    }
    
    

    Now, per datasheet, we can't use a pin's Alternate Functions as input unless the pin mode is one of the input modes:

    For alternate function inputs, the port must be configured in Input mode (floating, pullup
    or pull-down) and the input pin must be driven externally.

    There should probably be a conditional there - if pinMode is in manual mode, only un-manualize it and set it to input if it's not currently configured as input_pullup/input_pulldown.

    On the other hand, it's not much of a datasheet - more like a datatome of 700+ pages, so there may be some reason that you can't use the ADC with a pullup/down.

    That all said... according to the datasheet, the tolerances on the internal pullup/downs are wide enough to drive a truck through (nominal 40k ohm, but maybe as low as 30k or as high as 50k), so I question what one might be doing where the pullup would be acceptable in place of an external pullup. Unless it's a low impedance (so it effectively ignores the pullup) input that's intermittently connected, so you're trying to keep it from floating....

About

Avatar for DrAzzy @DrAzzy started