-
Notifications
You must be signed in to change notification settings - Fork 32
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
RP2040 + ICS-43432 issue #15
Comments
This is the gold standard on how to present an issue ! I have a theory on the issue: The SD line is staying high for a couple of bit times after the line has gone tri-state, after the 24th bit has been output, but only in the case where the 24th bit is high. For example, you see a 192 (0xC0), when bit 24 is high. Look at the bit immediately before a 192 result...it is always 1. When the last bit of the 3rd byte is 0, then the 4th byte is always 0x00. What's going on? There is always a small capacitance between SD and ground. When the mic tri-states the line (after the 3rd byte), and the line is high, there needs to be some resistance to ground to bring the line back to low, to discharge this capacitance. In your hardware setup with the Pico, the SD line is going low too slowly, hence the two high bits times (0xC0). When the line is already low, there is no capacitance to discharge, hence you see the expected value of the 4th byte (0x00). How to fix: It can be fixed in hardware. From the mic datasheet:
To test the theory -- add a smaller value pull-down resistor, between the SD signal and ground, e.g. 47k ohm, or 10k ohm. See if the 0xC0 value changes to 0x00. It might change to 0x80 which is moving in the right direction, but still indicates that a smaller resistor is needed to discharge the capacitance on the SD line. With the Raspberry Pi setup there may already be a resistor in place that discharges this capacitance at a faster rate. |
Maybe I'm misunderstanding you, but I don't see what you are saying:
Here the 192's come after zeros on the 3rd and 4th bytes.
It looks to me that the 4th byte is always the continuation of the sign, i.e. if the 24th bit (last bit of the 3rd byte) is 1, then the 4th byte if 0xff, 0x00 otherwise.
I would expect relevant data on my first byte, not 0x00. Am I missing something? Thanks! |
I see the confusion -- in my explanation I am using the byte ordering as output on the physical I2S SD line, as shown in figure 11 of the ICS-43432 datasheet. But it doesn't get translated to the MicroPython array in that same order. It's reversed. Here is a translation from the sample bytes that come from the actual device to the MicroPython buf[] array.
It might help to look at one of your samples, It appears on the SD line in this order, MS bit --> LS bit
I think this is the best I can explain it. |
And this must be the gold standard of explanation! Well, I think I found the real issue here: it got stuck in my head the idea that the ICS-43432 would transmit bytes with little endian format (i.e. LSB first), I even wrote it in the initial issue description! 🤦 I guess the idea came from the format used by ALSA to return data in my RPi code, and then the idea got reinforced by the fact that I saw non-zero data on the last byte (the famous 192), plus it made sense to me to see a sign continuation (unpulled tri-state) in what I assumed was the last transmitted byte which, in fact, was the first... @miketeachman sorry for wasting your time and thank you very much for your patience, much appreciated! Case closed! |
Hey, great ! I'm glad this issue didn't turn into a difficult debugging exercise. Understanding the data coming from I2S is not trivial. The byte ordering seems backwards from what is expected. Good luck with your projects. |
Hi @miketeachman, |
I'm not sure how to make it better. The appbuf[] has little-endian ordering and the comment indicates little-endian ordering. e.g. appbuf[i+3] = most-significant byte, appbuf[i] = least-significant byte. |
Well... you are right, it is indeed clear enough. While this issue is resolved, it looks like the one in my head isn't :) |
No worries. I can never remember endianness. When I commented the code I had to consult wikipedia to make sure the comment was correct. |
Hi @miketeachman,
As promised, here I am with my test results.
I'm using a ICS-43432 I2S MEMS mic. It outputs 24-bit data, little endian, every 64 clock cycles.
Here is its data sheet:
https://invensense.tdk.com/wp-content/uploads/2015/02/ICS-43432_DS.pdf
My test program:
Running on:
Some output:
What I noticed is that the first byte is always 0 or 192.
I've tried the same mic with a Raspberry Pi and some C code and that is not the case.
Can you think of anything causing this?
Thanks!
The text was updated successfully, but these errors were encountered: