adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.12k stars 1.22k forks source link

RP2350B: invalid microcontroller.cpu.temperature #9781

Closed bablokb closed 2 weeks ago

bablokb commented 3 weeks ago

CircuitPython version

Adafruit CircuitPython 9.2.0 on 2024-10-28; Pimoroni Pico Plus 2 with rp2350b

Code/REPL

>>> import microcontroller
>>> microcontroller.cpu.temperature
-1160.06

Behavior

see above

Description

This works fine on a Pico2 with a RP2350A. I don't have any other RP2350B board so I can't verify if it is board specific or due to the B-version of the chip.

Additional information

No response

jepler commented 2 weeks ago
 * RP2040, RP2350 QFN-60: User ADC inputs are on 0-3 (GPIO 26-29), the temperature sensor is on input 4.
 * RP2350 QFN-80 : User ADC inputs are on 0-7 (GPIO 40-47), the temperature sensor is on input 8.
/**
 * The ADC channel number of the on-board temperature sensor
 */
#ifndef ADC_TEMPERATURE_CHANNEL_NUM
#define ADC_TEMPERATURE_CHANNEL_NUM (NUM_ADC_CHANNELS - 1)
#endif

Looks like the hard-coded channel value in common_hal_mcu_processor_get_temperature should be changed to use this define instead.

Feel like you could pick this up and PR it? I don't have a 2350B handy to check if it works.

bablokb commented 2 weeks ago

Yes, I will do that. Won't be before Tuesday though.