Sending data using I2C on Simulink

조회 수: 25 (최근 30일)
Abdulrahman
Abdulrahman 2025년 12월 10일 15:48
댓글: Abdulrahman 2025년 12월 19일 15:34
I'm using Nucleo-G474RE to send a bit stream over Simulink, instead of receiving 24 bits on the oscilloscope i can read only 8 bits, which are supposed to be the 8 bits in the middle that have the address of the peripheral and the status of the I2C block gives me 516 which is not on the documentation from matlab.

채택된 답변

Aditya
Aditya 2025년 12월 17일 6:22
Hi Abdurahman,
Only 8 bits seen: Your Simulink I2C Write block is likely configured to send just 1 byte (the address), not all 24 bits (3 bytes).Fix: Set the "Data size" in the block to 3, and input a 3-byte array.Status 516: This is not a standard Simulink code; it may mean "bus busy" or an error from the STM32 HAL library.You can check the following to resolve the issue:
  1. Check your I2C Write block settings: send 3 bytes, not 1.
  2. Make sure your I2C wiring and pull-ups are correct.
  3. Adjust your oscilloscope to capture the full transmission.
  4. Try updating your STM32 support package.
  댓글 수: 1
Abdulrahman
Abdulrahman 2025년 12월 19일 15:34
Hi Aditya,
Thank you for your reply! It worked after trying out a few different solutions. I updated the the STM32 support package, and used a different pull up resistor, 56k Ohm. It looks like 516 means that nack has been received

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by