cancel
Showing results for 
Search instead for 
Did you mean: 

Magnetometer

ankushkhare89
Associate II
Posted on August 08, 2016 at 15:52

Hello folks, 

I am trying to implement magnetomter LIS3MDL with STM32F4. After reading the X, Y and Z axis register I am getting negative values as they are 2's complement. How can I transmit them on UART to see negative decimal value on hyperterminal ? 
1 REPLY 1
Posted on August 08, 2016 at 16:59

How can I transmit them on UART to see negative decimal value on hyperterminal ?

How would you convert any binary representation into ASCII? If you couldn't figure out the negation and repeated division by 10, you could use things like

http://www.cplusplus.com/reference/cstdlib/itoa/

or sprintf() and send the buffer.

sprintf(buffer,''%d,%d,%d\n'', x, y, z);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..