cancel
Showing results for 
Search instead for 
Did you mean: 

Triple ADC mode with DMA [STM32F4 discovery]

ronandouguet
Associate II
Posted on February 20, 2012 at 14:52

The original post was too long to process during our migration. Please click on the attachment to read the original post.
22 REPLIES 22
Posted on May 19, 2014 at 17:44

Is this the correct way to grab the values?

 

It's not how I'd do it, but I'm not the arbiter of correctness in all situations. It seems to involve more steps than necessary, but otherwise seems to be reasonable.

Also why does some example projects in the standard library multiply the converted value by 3300 then divide it by 0xFF, some also shift the converted value by 8.

 

Well the 3300 presumes that Vref is 3.3V and you want to convert the measurement to millivolts, the divide by 0xFFF (or 0x1000) scales the number based on the 12-bit range of the value, ie 0x000 would be 0 mV, 0xFFF would be 3300 mV. The math is done that way to keep the numbers as integers, and maintain precision. If you wanted volts you'd need to consider using floating point. If your Vref was 3.0V (like the DISCO) then the constant would be 3000 instead, or 2.85V would be 2850.

I don't know why you'd shift by 8, perhaps they are using 8-bit samples, not 12-bit, I have no context to work with.

Your hex-to-decimal conversion is correct assuming the value is in millivolts, and that the Vref was known correctly.

This is all very confusing to me...Could you please recommend a good tutorial somewhere?

I'm the wrong guy to ask, I can derive the math/mechanics from the documentation. I'm not sure I can point at anything sufficiently STM32 centric to be helpful.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hkamba
Associate II
Posted on May 19, 2014 at 18:21

Again, thanks for taking the time to explain.

You are right about 8-bit samples being used for the example where an 8 bit right shift is done. I checked the example.

I think I have all answers to my questions. Have a great day!

hkamba
Associate II
Posted on May 19, 2014 at 18:21

Again, thanks for taking the time to explain.

You are right about 8-bit samples being used for the example where an 8 bit right shift is done. I checked the example.

I think I have all answers to my questions. Have a great day!