sprintf with %f in interrupt handler creating problem
Dear all,
i am facing very strange problem with sprintf function .
i am using sprintf function in 1ms timer interrupt routine and it works fine. for example.
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
sprintf(uDisMsg, "%.1f", 258.6);
sprintf(lDisMsg, "%.1f", 25.3);
printf("%s %s\n",uDisMsg,lDisMsg);
}
but when i call any method from while(1) loop in main function like
while (1)
{
superloop();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
then sprintf sometimes outputs right result sometimes outputs to 0.0
if i don't call superloop() in while(1) then sprintf works fine.
i am not able to understand what problem it faces while calling any method in while(1).
Code formatting applied - please see How to insert source code for future reference.
