-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
ESP32 IDF4 Build - I2C.Setup function results in Invalid Arguments on clock speed #2589
Comments
This link seems to identify the problem. i2c_get_clk_src() proides clock selection functionality in the IDF V4.4 for the specific device.. |
testing is WIP |
Thanks! This all looks good - if you could get your changes as a PR (or just a patch I can apply) that'd be great. On the I2C pin front, on STM32 where we have a similar situation of hard-coded pins, we have a checkPinsForDevice function which calls So I think you could do:
Which would work if the pininfo file was correct - I'm not sure it is right now, I think we only do UART: https://github.com/espruino/Espruino/blob/master/boards/ESP32.py#L187-L190 But it would be a nice one to fix, as it's also used for the nice graphics in https://www.espruino.com/ESP32#gpio-pins - for example the one for an STM32 board shows what peripherals are where: https://www.espruino.com/Pico#pinout |
Thanks,Working toward PR. |
Thanks! I've just pushed changes that add the relevant data for I2C1 - I wasn't too sure about UART/SPI/etc on other boards |
…s to make nicer docs pages, maybe good for #2589) fix default pin for ESP32 SPI2
@gfwilliams reccomendations to use the jshFindPinForFunction() is now working , with his board definition file changes, in my test version with this code: In addition Ive changed ESP32.Py to include pin definitions for I2C2 with : Ive tested the setup in both the ESP32-C3 and ESP32 builds. These test builds are from the action workflows in my github clone of Espruino. The default Pins are now working on both for I2C1 and on the ESP32 for I2C2**. The debug logging you can see in the new I2Csetup function above results in the following test results:
(further test results and PR to follow) |
That looks excellent - thanks for your work on this! |
** regarding the default I2C2 pins on the ESP32. I have made sure that on both I2C1 and I2C2 the default pins have not changed from the previous Espruino builds to avoid any breaking changes. However: With this in mind I would suggest (And will change in my PR) adding this to the documentation for i2c.setup in jswrap-spi_i2c |
Have you been able to test? I would assume with ESP32 that what Espruino did was most likely wrong to begin with - so if you can change it to match what everyone else did I think it would be better to do that than to try and soldier on with nonstandard pins |
Hi , Yes I Did test, and rechecked today. Ive checked with an I2C desplay device including monitoring with a logic analyser. Conclusion as before: On an ESP32 target pre any changes (Espruino 2V24 ) using default (ie no config object passed in I2C.setup() ) , for correct operation a device needs to be wired with SDA on P22 and SCL on 21. This is opposite to the documentation and pinout diagrams ive found. |
Wow, ok - thanks! That's crazy. I wonder what's up with that then... |
…vert Debug =1 for build action workflow testing,
On final testing , I realised that setting the required clock speed was not just a matter of setlecting the correct clock via the . clk_flags (as discussed above). The IDF also uses the value passed in .master.clk_speed against the selected clock to set the actual speed. Speed setting tests using both of the available clocks on the ESP32-C3 were measured using the analyser and it was concludeded to hardcode the selection of the 2MZ XTAL clock by setting the .clk_flags to Zero. This gave an accurate clock speed up to 400 Khz (or 400000 bitrate setting) . I was not successful in setting a clock much higher than this accurately. Maybe my measurment method, wiring pullups etc, or just the device cant do it. So the final change in the jshI2CSetup Looked like this. This leaves the ESP32 device I2C speed selection as was before the change. |
Finally all builds were sucessfull in the github build workflow of my Espruino clone. So going to raise my first PR with these changes. :) |
Fix for issue #2589 - i2Csetup for ESP 32-C3
Just merged - thanks for all your work on this! It's great that you were able to check the speeds with the logic analyser too! |
An error occurs using espruino in the ESP32-C3 IDF 4 build. when setting up the i2C.
In more detail: When building with the command line:
BOARD=ESP32C3_IDF4 DEBUG=1 make flash
The error occurs when executing the espruino command:
I2C1.setup({scl:D9,sda:D8});
The error text is :
The text was updated successfully, but these errors were encountered: