5 years, 8 months ago.

Nrf51822 with thermistor. Get resistence or temperature

Hi I have a 10k thermistor and a fixed 10k resistor in order to make a voltage division. Both uC and thermistor are beeing powered with 3.3v and I have configured ACD engine like this:

NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled; NRF_ADC->CONFIG = (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos) | (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) | (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos) | (ADC_CONFIG_PSEL_AnalogInput1 << ADC_CONFIG_PSEL_Pos) | (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos);

To read value I do:

NRF_ADC->CONFIG &= ADC_CONFIG_PSEL_Msk; Check if input pin has been selected NRF_ADC->CONFIG |= ADC_CONFIG_PSEL_AnalogInput1 << ADC_CONFIG_PSEL_Pos; NRF_ADC->TASKS_START = 1; while (((NRF_ADC->BUSY & ADC_BUSY_BUSY_Msk) >> ADC_BUSY_BUSY_Pos) == ADC_BUSY_BUSY_Busy) {} return (uint16_t) NRF_ADC->RESULT;

Well, thermistor circuit feeds ADC input with a maximum of 1.65v and considering the prescalling, ADC input receives 0,55v max and ADC reference is 1.2v. Once scales (input vs reference) are different, How to get the right ADC value in order to calculate the resistence and to calculate then the temperature?

Is it possible to use ADC_CONFIG_REFSEL as 3.3v (VDD), in order to simplyfy the math? Which is the name of the define for it?

Be the first to answer this question.