We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I try to read value of timer of STM32L152VD and convert it to float type. The way I use is first define the below union:
typedef union { uint32_t timercount; float flowtime; }union_timercount; union_timercount flow;
then use function below:
uint32_t TIM_GetCounter(TIM_TypeDef* TIMx) { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); /* Get the Counter Register value */ return TIMx->CNT; }
I send it to serial port:
flow.timercount=TIM_GetCounter(TIM2); sprintf(str1,"\r\nu=%u f=%f",flow.timercount,flow.flowtime); uart_out_str(str1);
but what I read is: u=2248 f=0.000000 why float value is not being converted?