-
Notifications
You must be signed in to change notification settings - Fork 119
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
A little fixes for making work SAMD51 with I2S #85
base: master
Are you sure you want to change the base?
Conversation
It's still uncomplete, it is needed to modify DMA utility |
thanks! if you can also please remove the "// <--- ERROR SAMD51" comments? |
Of course, sorry for that! Probably there are more bugs ^^" |
Trying to build these changes for the Feather M4 Express, I still get compiler errors about undeclared I'm continuing to poke around and see if I can work out a fix. |
Adding #ifndef VARIANT_GCLK1_FREQ
#define VARIANT_GCLK1_FREQ (48000000UL)
#endif to I2S.h is sufficient to get the changes to compile for the Feather M4, but that's a hack. The call to |
Note that VARIANT_GCLK1_FREQ constant is defined on variant.h file of the board. Please check you have an updated version of Adafruit SAMD core, I have version 1.2.9. Here you have this file location on Windows: Adafruit Metro M4: Adafruit Feather M4: At the very begining of the file you must find this code:
This file is linked during compilation (it defines all your board pinout) so that constant cannot be missing at all. |
There's the problem. I'm using PlatformIO and PlatformIO is still on 1.2.3. PlatformIO doesn't have a self-service way to update, so... platformio/platformio-pkg-framework-arduinosam#8 |
I've done a bit more tinkering and I'm able to see some clock signals, just not the ones I expect. If I configure the I2S singleton thusly: I2S = I2SClass(I2S_DEVICE, I2S_CLOCK_GENERATOR, PIN_I2S_SDO, PIN_I2S_SCK, PIN_I2S_FS); ...then PIN_I2S_SCK ends up getting the serial clock at the expected frequency. But PIN_I2S_FS is getting the MCLK, not the frame select clock. So now I'm digging into the port config. (Actually, if I just use those pins as they're defined in variant.h for my board, the Feather M4 Express, I don't get any clock on any pins. But if I map them to other pins I get them. I'm not too concerned about that right now, so I'm focusing on the other issue right now.) |
@@ -145,9 +147,15 @@ int I2SClass::begin(int mode, long sampleRate, int bitsPerSample, bool driveCloc | |||
i2sd.setSlotSize(_deviceIndex, bitsPerSample); | |||
i2sd.setDataSize(_deviceIndex, bitsPerSample); | |||
|
|||
#if defined(__SAMD51__) | |||
pinPeripheral(_sckPin, PIO_I2S); | |||
pinPeripheral(_fsPin, PIO_I2S); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written, I get the bit sync clock (sampleRate * 2 * bitsPerSample) on the pin identified by _sckPin
and the master clock (sampleRate * 256) on the pin identified by _fsPin
. And with my mic connected to these pins nothing comes out of the mic's data pin. However, if I add another statement after these two:
pinPeripheral(10, PIO_I2S); // just used pin 10 for testing
I then in addition to the above I also get the frame sync clock (sampleRate) on the new pin (pin 10 in this case). And if I wire up the new pin to my mic instead of the old pin (_fsPin
), I get data out of my mic's data pin.
Despite seeing data coming out of the mic on the scope, I'm still getting all zeros reading it in my sketch, but this is progress of a kind.
A little fixes for making work SAMD51 with I2S