I am new to micro-controller programming . I am using STM32F091RC Nucleo board. I am trying to read the temperature using NTC thermistor of 10 kOhm. I burned the code on micro-controller and tried to see the output on STM Studio.
But my adc_value is stuck at 59390 for some reason. I don't see any change in temperature and I am not sure if I am doing it right. Can anyone help me?
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc;
UART_HandleTypeDef huart2;
uint16_t adc_val;
float R1, R2, R22, Tk, Tc, c1, c2, c3;
float sysTemperature, sysTemp_inmV, sysTemp_inCel;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
adc_val = HAL_ADC_GetValue(hadc);
R1 = 10000;
c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
R2 = R1 * ((4095/adc_val) - 1);
R22 = log(R2);
Tk = (1.0 / (c1 + c2*R22 + c3*R22*R22*R22));
Tc = Tk - 273.15;
HAL_ADC_Start_IT(hadc);
}
