Skip to main content
ankushkhare89
Associate II
August 8, 2016
Question

Magnetometer

  • August 8, 2016
  • 1 reply
  • 548 views
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 ? 
    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    August 8, 2016
    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 VenmoUp vote any posts that you find helpful, it shows what's working..