2018-07-06 05:09 AM
I have a problem with stm32f103, if insert in HAL_Delay(1000) in Serial Monitor i see incorrect results, but if i insert HAL_Delay(150) the results are correct. I do not understand why!
This is the code:
while (1)
{ HAL_ADC_Start(&hadc1); if(HAL_ADC_PollForConversion(&hadc1,10) == HAL_OK){ sensorVal = HAL_ADC_GetValue(&hadc1); HAL_ADC_Stop(&hadc1); } VSENSE = sensorVal*ADC_TO_VOLT; temperature = (V25 - VSENSE) / AVG_SLOPE + 25; char buffer[7]; sprintf(buffer, '%5.2f\n', temperature);HAL_GPIO_WritePin(LED13_GPIO_Port, LED13_Pin, GPIO_PIN_SET);
HAL_UART_Transmit(&huart1, (uint8_t*)buffer, sizeof(buffer) ,HAL_MAX_DELAY); HAL_GPIO_WritePin(LED13_GPIO_Port, LED13_Pin, GPIO_PIN_RESET); HAL_Delay(150);}
2018-07-06 05:36 AM
>>i see incorrect results
That's not exactly helpful to those not observing it directly.
>>I do not understand why!
Not exactly sure either, some chance you can post a more complete compilable code that illustrates?
2018-07-06 10:30 AM
If i use HAL_Delay(1000) the Serial Monitor show numeric value of temperature incorrect.