FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    What is the MPU 6050 corresponding to the I2C address? How to read data

     

    The MPU 6050 is actually an I2C device, there are many registers (but only a few of us), we use the read and write registers to operate this chip. Therefore, the primary problem is the I2C communication of STM32 and MPU 6050. 1. Configure STM32 (with I2C1: PB6 - SCL; PB7 - SDA) 1) Clock RCC RCC_APB2PeriPhClockCMD (RCC_APB2PeriPh_GPIOB, Enable); Rcc_apb1periphclockcmd (RCC_APB1PeriPH_i2c1, Enable); 2) GPIO configuration GPIO_INITSTRUCTURE.GPIO_PIN = GPIO_PIN_6 | GPIO_PIN_7; GPIO_INITSTRUCTURE.GPIO_SPEED = GPIO_SPEED_50MHz; GPIO_INITSTRUCTURE.GPIO_MODE = GPIO_MODE_AF_OD; // Two pins plus 4.7k pull-up resistor GPIO_INIT (GPIOB, & GPIO_INITSTRUCTURE); 3) I2C configuration Void I2C_Configuration (Void) { I2C_INITTYPEDEF I2C_INITSTRUCTURE I2C_INITSTRUCTURE.I2C_MODE = I2C_MODE_I2C; I2C_INITSTRUCTURE.I2C_DUTYCYCLE = I2C_Dutycycle_2; I2C_INITSTRUCTURE.I2C_OWNADDRESS1 = 0xc0; // STM32's own address, not the same as the slave I2C_INITSTRUCTURE.I2C_ACK = I2C_ACK_ENABLE; I2C_INITSTRUCTURE.I2C_ACKNOWEDGEDADDRESS = I2C_Acknowledged ADDRESS_7BIT; I2C_INITSTRUCTURE.I2C_ClockSpeed ​​= 100000; I2C_INIT (I2C1, & I2C_INITSTRUCTURE); I2C_CMD (i2c1, enable); } At this point, STM32 is configured, it is not so difficult. 2, initialization MPU6050 Void MPU6050_Initialize () // Initialization process, actually writing 5 registers { MPU6050_I2C_BYTEWRITE (0xD0, 0x00, MPU6050_RA_PWR_MGMT_1); // reg107, awakening, 8M internal clock source MPU6050_I2C_BYTEWRITE (0xD0, 0x07, MPU6050_RA_SMPLRT_DIV); // Using frequency 1000 MPU6050_I2C_BYTEWRITE (0xD0, 0x06, MPU6050_RA_CONFIG); MPU6050_I2C_BYTEWRITE (0xD0, 0x01, MPU6050_RA_ACCEL_CONFIG); // Acceleration Rule 2G MPU6050_I2C_BYTEWRITE (0xD0, 0x18, MPU6050_RA_GYRO_CONFIG); // angular velocity range 2000 degrees / s } Note: 0xD0 represents the address of the MPU 6050. We know that I2C is from the device (here, it means that the MPU 6050) has 8-bit addresses, the top 7 bits are determined by the WHO AM I, and the 8th bit is determined by the level of AD0. The WHO AM I default is 0x68h (1101000B), the AD0 is lowered, so the I2C address of the MPU 6050 is 0xD0H (11010000B). 3, I2C core program (read / write) 1) Write register One write operation is divided into several steps: send start signal - "start success? (Possible to describe it) - "Send the MPU 6050 address, the status (write) -" write address success? - "Send an MPU 6050 inside some to write register address -" Send success? - "Send the content to be written -" Send success? - "Send end signal Summary: First write the MPU6050 address, write the register address, last write content, and each time you have to verify (should be related to the response signal). This is like sending a courier, first writting the county address, then write the street address, and finally written the number. Look at the procedures below will be more likely to understand. Void MPU6050_I2C_ByTewrite (U8 Slaveaddr, U8 PBuffer, U8 WriteAddr) { / * Send start condition * / I2C_GenerateStart (I2C1, Enable); // Send start signal / * TEST ON EV5 and CLEAR IT * / While (! I2c_checkevent (i2c1, i2c_event_master_mode_select); / * Send MPU6050 Address for Write * / I2C_send7bitaddress (i2c1, slaveaddr, i2c_direction_transmitter); // Send MPU6050 address, status (write) / * TEST ON EV6 and CLEAR IT * / While (! I2c_checkevent (i2c1, i2c_event_master_transmitter_mode_selected); / * Send the MPU6050's Internal Address to Write to * / I2C_senddata (I2C1, WriteAddr); / / Send an internal to-write register address within the MPU 6050 / * TEST ON EV8 and CLEAR IT * / While (! I2c_checkevent (i2c1, i2c_event_master_byte_transmitted); / * Send the byte to be written * / I2C_senddata (I2C1, PBuffer); // Send content to be written / * TEST ON EV8 and CLEAR IT * / While (! I2c_checkevent (i2c1, i2c_event_master_byte_transmitted); / * Send Stop Condition * / I2C_GenerateStop (i2c1, enable); // Send end signal }, Read the full text, the technical area About μClinux transplantation on ARM7 S3C4510B Multi-looped into charge and discharge controller design Interrupt service routines for ARM embedded systems LED dimming engine design based on 8-bit MCU How to display Chinese characters, ASCII characters and color graphics on the LCD monitor

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us