I am using nRF_Connect_sdk and RTT logs.
In RTT logs, float numbers are not getting displayed.
I am getting just 0.00 for floating numbers.
Can you help me with how to display floating numbers on RTT logs?
hi,
Below is the code snippet:
#define float_num 10.234 /* Print the AIN0 values */ int ret; float adc_voltage = 0; ret = adc_read(adc_battery_voltage, &sequence); LOG_INF("ADC read err: %d\n", ret); adc_voltage = (float)(((float)m_sample_buffer[i] / 1023.0f) * 3600.0f); LOG_INF("ADC raw value: %d\n", m_sample_buffer[i]); LOG_INF("Measured voltage: %d mV\n", (int)adc_voltage); LOG_INF("Float Num: %0.3f \n", float_num); LOG_INF("Measured voltage: %0.2f mV\n", adc_voltage);
and here is RTT log:
So as you can see, when I print the value in integer format, it shows in log, else it displays 0.00 on RTT logs.
Bhumika said:So as you can see, when I print the value in integer format, it shows in log, else it displays 0.00 on RTT logs.
Thanks for the feedback, Bhumika!
Have you enabled the following configuration parameters in your prj.conf?
CONFIG_LOG=y CONFIG_LOG2_MODE_IMMEDIATE=y CONFIG_FPU=y
Regards,
Markus
Hi,
I have enabled the following,
CONFIG_LOG=y
CONFIG_FPU=y
but not
CONFIG_LOG2_MODE_IMMEDIATE=y
in prj.conf.
I will enable this as well, but can you explain to me the role of the "CONFIG_LOG2_MODE_IMMEDIATE" conf also?
Bhumika said:I will enable this as well, but can you explain to me the role of the "CONFIG_LOG2_MODE_IMMEDIATE" conf also?
CONFIG_LOG2_MODE_IMMEDIATE (or CONFIG_LOG2_MODE_DEFERRED alternatively) enable LOG2, which supports floating point operations.
Regards,
Markus