Sergii Kaplia
/
Internal_Temperature_F103RB1
test
Diff: main.cpp
- Revision:
- 1:09a5e83ea18f
- Parent:
- 0:dfdf46225b14
- Child:
- 2:bd6594739176
--- a/main.cpp Sun Mar 27 21:46:25 2016 +0000 +++ b/main.cpp Mon Mar 28 07:02:30 2016 +0000 @@ -2,7 +2,9 @@ #include "mbed.h" -// See STM32F103x datasheet, chapter 5.3.19 "Temperature sensor characteristics", Table 50. "TS characteristics" +// STM32F103x datasheet: +// 5.3.19 "Temperature sensor characteristics" +// Table 50. "TS characteristics", Page 80 const float AVG_SLOPE = 4.3E-03; const float V25 = 1.43; const float ACD_TO_VOLT = 3.3 / 4096; @@ -43,8 +45,11 @@ while(1) { myled = !myled; + // STM32F103xx Reference Manual: + // 11.10 Temperature sensor + // Reading the temperature, Page 235 HAL_ADC_Start(&hadc1); - while(HAL_ADC_PollForConversion(&hadc1, 0) != HAL_OK); + while(HAL_ADC_PollForConversion(&hadc1, 1000000) != HAL_OK); adcValue = HAL_ADC_GetValue(&hadc1); temp = (V25 - adcValue * ACD_TO_VOLT) / AVG_SLOPE + 25.0f; pc.printf("temp = %3.1f%cC\n", temp, 176);