arduino / ArduinoCore-mbed

348 stars 202 forks source link

GIGA R1: Reading MCU temp using analogRead(ADC_TEMP) returns -1 #959

Open megacct opened 1 month ago

megacct commented 1 month ago

I was hoping to read the MCU internal temp sensor connected to ADC3_IN18 via the ADC_TEMP define. It would appear this isn't implemented correctly (possibly in mbed os)

megacct commented 1 month ago

If anyone wants this now:

mbed::AnalogIn mcuADCTemp(ADC_TEMP);
.....
mcuTemp = __HAL_ADC_CALC_TEMPERATURE (3300, mcuADCTemp.read_u16(), ADC_RESOLUTION_16B);

will give a rough value. You can tune the internal voltage (3300mv above) to your actual internal mV and there are other mbed macros for doing that