← index #1681Issue #6219
Related · high · value 0.214
QUERY · ISSUE

stmhal: ADC class only uses ADC1 hardware

openby blmorrisopened 2015-12-04updated 2024-08-28
enhancementportsport-stm32

This issue appears not to be very minor for the pyboard or any board using 64- or 100-pin versions of the STM32F405, so it could be low-priority or 'won't fix'. However, I encountered this running MicroPython on an Olimex STM32-E407 dev board, which uses a 144-pin STM32F407. On this board, much of the GPIO from ports A, B, and C are connected to / utilized by on-board peripherals (like an Ethernet PHY). Most of the ADC input pins that are broken out to headers are on Port F, but those ADC pins are only connected internally to ADC3, so not accessible via the current ADC class:

>>> pf6 = pyb.ADC('PF6')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: pin F6 does not have ADC capabilities
>>> 

Since I am already customizing the firmware a bit to get it running on the Olimex board, I think that I can solve my immediate problem by hacking a few lines in adc.c to use ADC3 instead of ADC1. I don't have a more generic solution yet, so I just wanted to raise the issue before I forgot about it.

The biggest potential benefit that I could see in enabling the ADC2 and ADC3 hardware for lower pin-count chips would be to enable high-speed interleaved ADC reads on those pins connected to all three instances, but it would take some serious recoding to allow this, for an application that may see relatively little use.

CANDIDATE · ISSUE

[ESP32] Read from ADC2 Pins

closedby jdjjmopened 2020-07-02updated 2022-02-02
port-esp32

Is there any way of accessing ADC2 Pins?
Even with WiFi off you cannot set up an ADC on any of the ADC2 Pins as you get the error
ValueError: invalid Pin for ADC

Looking at the esp32 port for machine_adc.c it seems only adc1 pins are supported. Is there any way to use ADC2?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied