I2C MMA8452 Accelerometer


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2013
    Posts
    6

    Default I2C MMA8452 Accelerometer

    I connected to the I2C bus 4 chips that work perfect ,I can read and write without any problem,
    (2 x PCA9532 - LED drivers,MAX17043 - Fuel Gauge, DS1307 - RTC).but the MMA8452 returns only zeros.
    I tried slow ans high speeds,I2C_HOLD but failed.
    I use the PIC18F2553 at 48MHz
    The compiler is PBP 2.6
    Help,Please....

  2. #2
    Join Date
    Aug 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer

    I read the datasheet and it says:"Single Byte ReadThe MMA8453Q has an internal ADC that can sample, convert and return sensor data on request. The transmission of an
    8-bit command begins on the falling edge of SCL. After the eight clock cycles are used to send the command, note that the data
    returned is sent with the MSB first once the data is received. Figure 11 shows the timing diagram for the accelerometer 8-bit I2C
    read operation. The Master (or MCU) transmits a start condition (ST) to the MMA8453Q, slave address ($1D), with the R/W bit
    set to “0” for a write, and the MMA8453Q sends an acknowledgement. Then the Master (or MCU) transmits the address of the
    register to read and the MMA8453Q sends an acknowledgement. The Master (or MCU) transmits a repeated start condition (SR)
    and then addresses the MMA8453Q ($1D) with the R/W bit set to “1” for a read from the previously selected register. The Slave
    then acknowledges and transmits the data from the requested register. The Master does not acknowledge (NAK) the transmitted
    data, but transmits a stop condition to end the data transfer."
    How can I send a repeated start?

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer

    Quote Originally Posted by emf985 View Post
    but the MMA8452 returns only zeros.
    I assume that you are using a different address for every device. Isolate the MMA8452 and try to communicate with it first.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    Join Date
    Aug 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer

    Thanks
    Yes,of course ,the problem, as I see it , is that the pbp cannot produce a repeated start .
    I used a logic analizer -----> the accelerometer sends acknowlage signals.
    the data sheet demands an Sr (repeat start) in order to read the device.
    the device resets the address register to zero if the master sends a STOP.
    I can read only the top seven registers only.(there are a lot of registers).

  5. #5
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer


  6. #6
    Join Date
    Aug 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer

    Thanks,I read it,( there is no part 2) .
    I used PBP I2CREAD and I2CWRITE instructions .
    Maby there is something to be done with the instructions we have,I hope I'll not be forced to write new I2C subrutines just for this device.(hopefully somone did write it)

  7. #7
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: I2C MMA8452 Accelerometer

    This is I2C write:
    GOSUB INT_ROM
    SHIFTOUT DPIN,CPIN,1,[DATO\8,%1\1]
    GOSUB STOP_ROM

    I2CREAD:
    GOSUB INT_ROM
    GOSUB START_ROM
    SHIFTOUT DPIN,CPIN,1,[CONT1]
    SHIFTIN DPIN,CPIN,0,[ACK\1,DATI\8]
    SHIFTOUT DPIN,CPIN,1,[%1\1]
    GOSUB STOP_ROM

    This is start sequence:
    START_ROM:
    HIGH CPIN:HIGH DPIN:LOW DPIN:RETURN

    Every thing is already done...

Similar Threads

  1. 3-Axis Accelerometer (LIS302DL)
    By Gusse in forum Code Examples
    Replies: 20
    Last Post: - 28th January 2013, 04:20
  2. Accelerometer reading
    By joseph Degorio in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th February 2011, 11:43
  3. accelerometer question
    By griffin in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 27th February 2009, 21:00
  4. Accelerometer Sensor
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 27th August 2008, 13:26
  5. Adxl213ae Accelerometer
    By DougB in forum mel PIC BASIC
    Replies: 0
    Last Post: - 25th July 2005, 21:32

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts