guild icon
Toit
#ESP32-C3 A3 (GPIO5) not usable.
Thread channel in help
kaxori
kaxori 07/22/2023 09:16 AM
jaguar report:
**
Decoding by jag, device has version <2.0.0-alpha.90>
**
EXCEPTION error.
OUT_OF_RANGE
0: adcinit <sdk>\gpio\adc.toit:101:3
1: Adc <sdk>\gpio\adc.toit:58:17
2: main soilSensor.toit:423:9
**

C3 has 4 ADCs A0..A3 on ports GPIO2..GPIO5.
Why is A3 not usable?
kaxori
kaxori 07/22/2023 09:58 AM
Answered in lib/gpio/pin.toit:
==> Pin 5 is an ADC pin of channel 2. ADC channel 2 has restrictions and should be
avoided if possible
.
floitsch
floitsch 07/22/2023 11:41 AM
Yeah. This is a bit annoying.
Typically, we try to provide better error messages, but here the error message comes from the underlying C code (the primitive). And the errors that can come from there are a bit limited.
We can't easily test for the pin numbers in Toit code already, as the pins are different depending on the Target (esp32, esp32c3, ...), and we don't want to change the Toit code for every possible hardware. This means that it's currently just an OUT_OF_RANGE...
3 messages in total