-
Notifications
You must be signed in to change notification settings - Fork 5
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
Failed IMU begin with error code -12 #14
Comments
Thank you for opening this issue! We will look into it shortly. |
Hello @SorabhR, Could you please you provide a trace of the SPI signals using scope or logic analyzer? Regards, |
I am sorry I don't have a logic analyser. But I tried raw code of spi reading the who_am_i register of the imu and that is working fine. |
Could you please check the value you read for the who am i? |
I got 0x67 for who_am_i |
Thanks, perfect so SPI signals integrity is OK. |
#include <SPI.h> // Define pins void setup() { // Initialize SPI SPI.begin(); // Set CS pin as output pinMode(CS_PIN, OUTPUT); Serial.begin(115200); } void loop() { // Select the ICM-42670-P digitalWrite(CS_PIN, LOW); // Send a command (example: read from a register, 0x75 is WHO_AM_I register) SPI.transfer(0x75 | 0x80); // Send WHO_AM_I command (read bit is 1) SPI.transfer(0x00); // Read the response // Deselect the ICM-42670-P digitalWrite(CS_PIN, HIGH); Serial.print("WHO_AM_I response: "); delay(1000); |
You don't use Arduino SPI.beginTransaction() method ? |
I have used the default spi mode |
Could you share the Arduino sketch source code ? |
I have used this code only exactly |
Do you call following lines somewhere?: (sorry for the terrible questions, but I need to reduce the scope to understand what could be the issue) |
During the examples code of the library yes I do call it but in my raw code I do not Infact IMU.begin only fails |
Do you confirm that you use 10 in ICM42670 IMU(SPI,10); ? (default is pin 8) |
Yes I did that change |
Ok can you try to add the following line in your raw code before starting the who am i read (before digitalWrite(CS_PIN, LOW);): |
Okay I will try that and let you know |
Yes sure, try other valuesfor SPI clock frequecy and SPI_MODE parameters. |
Does the library use SPI3 and 6MHz clock? |
Yes exactly! |
So as far as I understand library uses SPI mode 3 what if the sensor does not work on that and only works on spi mode 0? |
Another possible issue, other than SPI settings, could be the delay function: |
I am using espcore3 in Arduino ide 2.1 So spi mode 0 and mode 3 both should work. |
Hey |
And with SPI clock @6MHz? |
Yes that's working too |
Ok many thanks for these tests and feedback. Let's try validating the delayMicroseconds.... And check that the increment between the 2 println is around 1000us. Regards, |
Yeah so the difference between the two millis is of 1 which is 1000us |
That's correct ! Alternatively, you could modify the Documents\Libraries\Arduino\ICM42670\src\ICM42670.cpp in function spi_read, something like following, to check every parameters: |
Could you please add Serial.println(obj->spi_cs); and Serial.println(reg); |
10000000 Suddenly it started working but giving garbage values |
Hello @SorabhR , |
Hey |
But with mode0 it is working fine so what would changing slew rate help in? |
If SPI signals are not fully safe you will probably have other issues later in your dev. |
So In spi mode 0 I should change the slew rate but when I change the spimode3 will re powering both sensor and esp cause the settings to go back to factory default? |
The slew rate is reset at power up. |
So should I set that in the Imu.begin function? |
Yes before inv_imu_init, you could do something like: |
Okay |
Hello @SorabhR, Any feedback on that test? Regards, |
Hey |
@SorabhR and @rbuisson-invn any update on this issue? I am encountering the same issue, ( i have tried to change slew rate) and being trying both SPI4 and SPI3. The error code -12 happens to me after executing |
Hello @kjs-eir, Could you please share any capture of the SPI signals? Thanks and regards, |
Hi @kjs-eir , |
Sure. For my evaluation board setup I use a Psoc6 MCU (Also on a custom PCB, but with way more test-points) and the DK-42670-P eval board. The connection is made via J4, where I connect MISO, MOSI, SCLK, CS, INT1, INT2, GND. I also connect a 3.3V source from my MCU. On DK-42670-P I have a jumper on J3 between 3V3 and VDDIO. This makes me able to power the DK-42670-P with out external power, and then I can power up the ICM42670P and get IMU via SPI. My second setup is a custom made PCB, but with the same MCU, and a ICM4670P. The connection are as shown on my previous picture, where SPI_MISO_IMU, SPI_MOSI_IMU, SPI_CLK_IMU, SPI_CS_IMU and IMU_INT are connected to the respective SPI-compatible GPIO on the MCU. IMU_WAKE is connected to a buck-boost converter, with the intension of using WOM. But here I encounter the issue with error code -12 when trying to reset the IMU. I hope this make it easier to understand the issue, otherwise let me know. Thanks, |
HI @kjs-eir , |
Yes, the same model and rev, both a PSOC6, and I am flashing the same FW image on both setup. Thanks, |
HI @kjs-eir , |
I have no pull-up on neither of INT1 or INT2. I can try and add one to INT1 via the configurable HW blocks in PSOC6, but doing that on INT2 is more tricky. Any other leads/ideas? Thanks, |
HI @kjs-eir , |
Hi @sriccardi-invn Regards |
Hello @kjs-eir , Could you please try the following change in the ICP42670P library:
|
Thanks for the input. I tried to add the lines for updating DRIVE_CONFIG3, but the issue persist. To clarify a bit more, it is when executing
Data become 0xff, resulting in INV_ERROR_UNEXPECTED |
Hello @kjs-eir , Thanks for the feedback. The best way to proceed would be to get the SPI traces on the failing board, to understand what the issue could be. Regards, |
@rbuisson-invn maybe this is a long shot. But the eval kit has a external pull-down on the FSYNC pin, but my setup doesn't have that and the datasheet says it ok to connect it directly to ground? |
Hello, This should not be a problem. Regards, |
Hey,
I have DK-42670-P development board.
The spi pins are out on J4 for the development board. I have connected my esp32s3 spi pins there.
But I am unable to initialise the IMU it is failing with error code -12.
Please help if you have any idea to resolve this.
The text was updated successfully, but these errors were encountered: