Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i2c speed incorrect after error (IDFGH-12366) #13397

Closed
3 tasks done
pggh opened this issue Mar 16, 2024 · 4 comments
Closed
3 tasks done

i2c speed incorrect after error (IDFGH-12366) #13397

pggh opened this issue Mar 16, 2024 · 4 comments
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@pggh
Copy link

pggh commented Mar 16, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.1 and 5.2.1

Espressif SoC revision.

ESP32S3

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

own

Power Supply used.

External 5V

What is the expected behavior?

Actual speed on i2c to be as set in i2c_config_t.master.clk_speed

What is the actual behavior?

I configure i2c master with i2c_param_config and clock speed 10'000 Hz and start the driver with i2c_driver_install.
No device attached to the bus (plug&play scenario).
The first write to the device fails as expected and is using 10'000 Hz clock.
From the second write on the clock is 40'000 Hz (measured with idf 5.1).
For comparison, when doing the same with 100'000 Hz (or 40'000 Hz) the clock on the second write is the same as on the first write, as it should be.

Steps to reproduce.

Excerpt from the test program:

stop is true, n is 1

   const auto l = i2c_cmd_link_create();
   switch (state) {
   case S_READ:
      i2c_master_stop(l);
      break;
   case S_CLOSED:
   case S_STOPPED:
      i2c_master_start(l);
      i2c_master_write_byte(l, (slave_addr << 1) | I2C_MASTER_WRITE, true);
      break;
   default:;
   }
   i2c_master_write(l, buf, n, true);
   if (stop) {
      i2c_master_stop(l);
   }
   const auto stat = i2c_master_cmd_begin(i2c_num, l, pdMS_TO_TICKS(100));
   i2c_cmd_link_delete(l);
   if (stat == ESP_OK) {
      state = stop ? S_STOPPED : S_WRITE;
      printf("wrote:");
      for (unsigned i = 0; i < n; ++i) { printf(" %02X", static_cast<unsigned>(buf[i])); }
      printf(" %s\n", stop ? "stop" : "nostop");
   } else {
      state = S_STOPPED;
      const auto ls = i2c_cmd_link_create();
      i2c_master_stop(ls);
      i2c_master_cmd_begin(i2c_num, ls, pdMS_TO_TICKS(10));
      i2c_cmd_link_delete(ls);
      printf("i2c write failed with %u\n", stat);
      return 2;
   }

   return 0;

Debug Logs.

No response

More Information.

No response

@pggh pggh added the Type: Bug bugs in IDF label Mar 16, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 16, 2024
@github-actions github-actions bot changed the title i2c speed incorrect after error i2c speed incorrect after error (IDFGH-12366) Mar 16, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new labels Mar 21, 2024
@pggh
Copy link
Author

pggh commented Mar 21, 2024

When will this be fixed?

@KonssnoK
Copy link
Contributor

@nebkat is this issue present also on v4.4 ?

@nebkat
Copy link
Contributor

nebkat commented Jul 31, 2024

@KonssnoK I am not a maintainer here - but AFAIK there were no major changes to I2C between 4.4 and 5.1, so it is not impossible that this would also apply to 4.4. You'll have to check the exact source contents to verify.

@KonssnoK
Copy link
Contributor

KonssnoK commented Aug 3, 2024

@nebkat sorry i saw you committed something and assumed you were involved :D
thanks anyway, we found the issue we were having

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants