#6. STM32 I2C Receive using Register based Programming || Multiple Bytes || MPU6050

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2025

ความคิดเห็น • 50

  • @Electronics_Dreams
    @Electronics_Dreams 3 ปีที่แล้ว +6

    Hi!! I'm writing from Argentina.. I found this channel and it's gold! I really enjoy your videos. Saludos y sigue así!

  • @joecandoit5341
    @joecandoit5341 3 ปีที่แล้ว

    You are still a legend. Now I understand why the ACK enable is there. You are on my "if I ever make money with this stuff, I am sending you some" list lol.

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      Yeah.. i have mixed both tx and rx. It's always better to use Ack even with tx only.

  • @Jair_inacio_Neto_Teixeira
    @Jair_inacio_Neto_Teixeira 3 ปีที่แล้ว +2

    Amazing! It would be nice if you make a video using registers to control an spi lcd tft screen

  • @hasanyilmaz946
    @hasanyilmaz946 3 ปีที่แล้ว +1

    can you make a video about using lora module ?

  • @poincareelcartografo5406
    @poincareelcartografo5406 ปีที่แล้ว

    Thanks for your tutorials! They are of great help to me.
    Why don't you use your own built-in functions? For example, Step 2.a) and 2.b) together are the same as the I2C_Address(addr) function.

  • @СергейДробышевский-ю1з
    @СергейДробышевский-ю1з ปีที่แล้ว

    Good afternoon Thank you so much for your lessons!
    I spent 2 days writing code to receive data over I2C. Everything was good except...
    after receiving bytes, my MASTER RECEIVER do not send ASK! I spent 2 days! nothing helped!
    Your lesson helped! Thank you!
    My question is: you changed the I2C_Start procedure, namely, you added I2C1->CR1 |=(1

    • @ControllersTech
      @ControllersTech  ปีที่แล้ว

      Isn't ACK a common practice in communication ?
      I didn't knew about it. CR Register had an option to enable it, so I did.

  • @MirusWoozy
    @MirusWoozy 3 ปีที่แล้ว

    Great stuff as usual. Thank you so much! I can't read any changing value from the MPU6050. Do I need to connect SDA and SCL to propers pull-up resistors?

  • @poincareelcartografo5406
    @poincareelcartografo5406 ปีที่แล้ว

    The I2C works for me: I can see on the oscilloscope how every second the while loop is executed. But in the watch Ax, Ay and Az are at 0.
    In the oscilloscope I can see the signal perfectly: How the master sends the sequence: address, write, ACK(from the slave), register, ACK(from the slave), address, read, ACK(from the slave)... but from then on the acerometer only sends zeros.
    I thought that the accelerometer did not work well, but I have tested it with an arduino uno and it works perfectly.

  • @metehandemirel4914
    @metehandemirel4914 8 หลายเดือนก่อน

    Hi I used this code on STM32F407 since the registers are pretty much the same. But in my mcu the SB bit doesn't get set. The code gets stuck there. Any suggestions?

  • @pabloolguin818
    @pabloolguin818 2 ปีที่แล้ว

    Hi!
    I would like to know how to implement DMA to read acceleration through I2C?. I used HAL library but doesn’t work fine :( .

  • @tuanvo3108
    @tuanvo3108 ปีที่แล้ว

    Does the MPU_Read() function do the reading Low value of gyro or accel register also? Thanks in advance.

    • @ControllersTech
      @ControllersTech  ปีที่แล้ว +1

      What do you mean low value ?

    • @tuanvo3108
      @tuanvo3108 ปีที่แล้ว

      @@ControllersTech I mean the ACC_OUT_L, I thought it only read the HIGH value ( ACC_OUT_H at register 15:8 bits). But after a couple of minutes rewatching your code, I figured out that It reads the LOW values (7:0 bits) also. Thanks for replying anyways

  • @huseyinulupinar392
    @huseyinulupinar392 3 ปีที่แล้ว

    first of all it is very nice, which pins on MPU6050 are connected to which pins on STM ?

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      I2c pins. Clock to clock and data to data..
      See the mpu6050 detailed tutorial for that..
      Search on the website or youtube

    • @huseyinulupinar392
      @huseyinulupinar392 3 ปีที่แล้ว

      @@ControllersTech No, you got it wrong. Which pins of the SCL,SDA nucleo do I connect? I asked?

    • @huseyinulupinar392
      @huseyinulupinar392 3 ปีที่แล้ว

      @@ControllersTech more precisely the wiring diagram

    • @ControllersTech
      @ControllersTech  3 ปีที่แล้ว

      Did you watch the previous video ? About I2C send data
      The pin configuration is defined there. I said in the video that you must watch that one first

    • @huseyinulupinar392
      @huseyinulupinar392 3 ปีที่แล้ว

      @@ControllersTech unfortunately :( Can you leave the link?

  • @viaa3301
    @viaa3301 3 ปีที่แล้ว

    Hey, do u have some Tutorial about I2C on FreeRTOS with communicate LCD Display? i can send some lcd_init() but not completely, trying it witch void lcd (void *argument) { lcd_init()} and creat_lcd_task(lcd,"lcd,",512,Null,1,Null)

  • @vinothkannanr2804
    @vinothkannanr2804 3 ปีที่แล้ว

    what is the buffer size if i want to read 2 bytes of data

  • @gowthamt3802
    @gowthamt3802 3 ปีที่แล้ว

    How can i receive the data from another controller through i2c bus?

  • @pallaviroyal4170
    @pallaviroyal4170 ปีที่แล้ว

    Hi Good evening!!! Can you please do a video on Data transfer through i2c communication between 2 stm32f407discovery boards in stmcubeide without hal functions pleaseeee

  • @singhrobotics
    @singhrobotics 2 ปีที่แล้ว

    if i want to use different SCL and SDA PINS for I2C, is there a way to configure them?
    meaning i don't want to use PA8 and PA9 pins but some other GPIOs for I2C. how to configure different GPIOs as SCL and SDA pins for a given I2C (let us say I2C1)?

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      Its shown in the video.

    • @singhrobotics
      @singhrobotics 2 ปีที่แล้ว

      @@ControllersTech so this is in different video of yours.
      th-cam.com/video/usvAIEdp_I8/w-d-xo.html
      So i can configure any pin to be i2c taking reference from this part of your video?

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      Not any pins, the pins which support I2C. You can check that in the datasheet of your controller.

  • @DAREDEVIL-lj2we
    @DAREDEVIL-lj2we 2 ปีที่แล้ว

    can you explain why you have set MPU6050_ADDR as 0xD0(line 27) where as in the datasheet its given as 0x68/0x69 depending on AD0 value

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      As per the datasheet, the address is b110100X (X is for AD0). This address is 7 bit long.
      STM32 needs 8 bit Address for the I2C, So b110100XW (Here W is Write(0) or Read(1) But). basically b11010000, 0xD0

    • @DAREDEVIL-lj2we
      @DAREDEVIL-lj2we 2 ปีที่แล้ว

      @@ControllersTech basically 0x68

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      yes

  • @snookiewozo
    @snookiewozo 3 ปีที่แล้ว

    Fantastic. Subscribed.

  • @mirhatozkan5772
    @mirhatozkan5772 2 ปีที่แล้ว

    İt is great video but SB flag bit is never set, why? Thanks for help

  • @KARANKUMARKPHI
    @KARANKUMARKPHI 2 ปีที่แล้ว

    How do transfer data from the buffer memory to the PC?

    • @ControllersTech
      @ControllersTech  2 ปีที่แล้ว

      Use uart.. it's the easiest way

    • @KARANKUMARKPHI
      @KARANKUMARKPHI 2 ปีที่แล้ว

      @@ControllersTech I tried but not getting that.... Have you posted any videos related to buffer memory?

  • @erkamkocaer2097
    @erkamkocaer2097 3 ปีที่แล้ว

    There is something wrong in my code because when I trying to work MPU_Write(MPU6050_ADDR, PWR_MGMT_1_REG, Data);
    the code got stuck into this void I2C_Address(uint8_t Address) function's while loop. How can I fix this situation?

    • @MirusWoozy
      @MirusWoozy 3 ปีที่แล้ว

      It's exactly my situation. If you solved this issue, do you remember how? Thank you so much!

  • @Astinahsra
    @Astinahsra 3 ปีที่แล้ว

    love you!!!!!!!

  • @peterstudio9602
    @peterstudio9602 3 ปีที่แล้ว +1

    Thank You very much)))))

  • @kevingai370
    @kevingai370 4 หลายเดือนก่อน

    ur using keil.

  • @adityaoza3367
    @adityaoza3367 3 ปีที่แล้ว

    Thank you great

  • @jasonjoe7637
    @jasonjoe7637 3 ปีที่แล้ว +1

    good video,and I hope you can make a tutorial about how to calculate pitch,yaw and roll angle😄

  • @poincareelcartografo5406
    @poincareelcartografo5406 ปีที่แล้ว

    Thanks for sharing your knowledge! It is helping me a lot.
    I think the second step can be done more compactly like this:
    //2.-
    else
    {
    //2.a) and b)
    I2C_Address(addr);

    //2.c), d), e), f) and g)
    while(remaining)
    {
    while(!(I2C1->SR1 & I2C_SR1_RXNE)); //2.c)
    buff[size - remaining] = I2C1->DR; //2.d)
    if(remaining > 2)
    {
    I2C1->CR1 |= I2C_CR1_ACK; //2.e)
    remaining--;
    }
    else if(remaining > 1)
    {
    I2C1->CR1 &= ~I2C_CR1_ACK; //2.f)
    I2C_Stop(); //2.g)
    remaining--;
    }
    else
    {
    remaining--;
    }
    }
    }

    • @hhh123uh
      @hhh123uh 7 หลายเดือนก่อน

      does your function operate ok ?