Author Topic: Where I'm keeping my Code  (Read 975 times)

kbrooking

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Where I'm keeping my Code
« on: September 18, 2016, 08:05:14 pm »
Hello Nick,

In the below code snippet from the MMA8652 library, the whoAmI() function call is returning 0x00 and so the Accelerometer is never enabled.
Any suggestions as to why it is not returning 0x4a?

Public Sub New()
        gAccelerometer = I2c.Create(I2C_SPEED, Pin.SCL, Pin.SDA, I2C_ADDR)
        If whoAmI() = 0x4a Then
            online = True
            reset()
            // Set interrupt active low
            write(CTRL_REG3, read(CTRL_REG3) & ~IPOL_MASK) // clear bit 1 (active low)
            // Set interrupt push/pull
            write(CTRL_REG3, read(CTRL_REG3) & ~PP_OD_MASK) // clear bit 0 (push-pull)
        End If
    End Sub