Dec 19, 2014
12:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 19, 2014
12:07 AM
Good day,
Please advise how convert data from ADC to float format?
I get data from ADC result register in uint16_t variable and see reasonable data at debugging (Like 16363).
What shall I do next to convert it to float32_t format?
BR
K
Please advise how convert data from ADC to float format?
I get data from ADC result register in uint16_t variable and see reasonable data at debugging (Like 16363).
What shall I do next to convert it to float32_t format?
BR
K
- Tags:
- IFX
3 Replies
Dec 19, 2014
12:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 19, 2014
12:57 AM
For 10 bit ADC and Vref at 3.3V, then the total step is 1024. Please note that only the first 16bit of the result register shows the conversion result.
Example:
uint32_t ADC_value;
float result;
ADC_value = Read_AD(); // only the first 16bit is the AD result
result = (ADC_value/1024) * 3.3;
Example:
uint32_t ADC_value;
float result;
ADC_value = Read_AD(); // only the first 16bit is the AD result
result = (ADC_value/1024) * 3.3;
Not applicable
Dec 19, 2014
01:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 19, 2014
01:05 AM
Hi,
You can just declare another float variable and put the result from uint16_t into it.
You can just declare another float variable and put the result from uint16_t into it.
uint16_t var_A;
float var_F;
var_F = (float)var_A;
Dec 19, 2014
06:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 19, 2014
06:44 AM
Good day Jackson,
Thanks, it's working!:)
BR
K
Thanks, it's working!:)
BR
K