-
Notifications
You must be signed in to change notification settings - Fork 423
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
Palmerr23 i2 s mclk #1555
Palmerr23 i2 s mclk #1555
Conversation
Hold off on this Earle - the update to the board files has broken a few things. |
add doco for setMCLK(pin_size_t pin) setMCLKmult(int mult) setSysClk(int samplerate)
I2S doco update
I think everything is OK now. Multiple copy and pastes to align my PR with the 3.3.0 release that occurred midway in development of this code. |
Sorry Linus, I'll fix it. |
Reinserted #1548 code from Linus. |
Can you run Also, it looks like that maybe there are some old/missing files:
|
Will do, probably tomorrow. |
Since I'm also using MCLK I'm eagerly following the PR ^^ To stay consistent with current code, shouldn't you also stop the MCLK PIO upon I2S.end()? I have a use-case where I switch back and forth between I2S and PWM, repeatedly calling I2S.begin/end. |
Also, maybe I missed it, but there is no default value for |
Jeremy, That is correct. As this is an independent PIO program and not using multiple pins, any legitimate pin can be assigned as for DIN/DOUT. |
Jfrey, Yes. I'll add code to terminate the MCLK PIO program on I2S exit. |
|
Good point. I think PIN 27 makes a more sensible default than PIN 0. |
I would suggest that, by default, no pin is used since most codecs don't require it. Set the default pin to |
Oops! make that pin 25, pin 27 is LRCLK. |
Earle, Yes that's the default behaviour: MCLK is not driven unless the MCLK pin is set. There is no harm, however in Jeremy's suggestion that a default be set (and not assigned to anything active) in the constructor. I've also added a default of 256 for _multMCLK I'll run the tidy-up routine and update the pull, once I've tested the additions. |
Updates now restyled with restyle.sh Additions of default pins and stopping MCKL in i2s.end() now tested. |
I wrote some code to test all possible sysclk and PIO divider permutations. There may be more at higher sysclks, but I stopped checking at 200MHz. The two I have suggested in the doco are: I found two further 'good' sysclks: While these are even closer to the desired sample rates, they are more overclocked. Should I include them in the doco for completeness? |
Took some time, but looks like it's building OK finally! Because this is a little big, I'll need a few days to look it over. If anyone watching the PR could give it a try in their application that would be great, too. |
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.
Very nice work and thanks for the effort in packaging it up. Some really minor niggles and I think we're all set!
Oh, and double thanks for actually adding documentation for your changes!!! |
Thanks Earle and Linus, I'll get to all the minor issues - in which you are both correct in all cases. It might take a few days, as my fork seems to be out of date with the base branch. I rarely use git in community contribution mode and I'm not sure how to bring my fork into line without overwriting all my changes, as it did last time when I hit the "update branch" button. I'd rather abandon the pull than go through that pain again! For the one below, I was intending to release the pin, rather than set it to false. My bad, not having written a lot of PIO code. Clearly, once the PIO code abort, it will no longer try to change the pin value, and PIO to pin mappings are not exclusive.
Richard |
Don't worry about the update, just do your changes and push. The online FWIW I normally just do the |
:-)
Thanks
…_________________________
Richard Palmer
0417 514 473
On Mon, 3 Jul 2023 at 13:01, Earle F. Philhower, III < ***@***.***> wrote:
Don't worry about the update, just do your changes and push. The online update
branch button has never given me any trouble (and if there are any
conflicts they can be edited online by me if needed).
FWIW I normally just do the update branch from the web interface and then
just git pull while in my editing branch and things generally "just work."
—
Reply to this email directly, view it on GitHub
<#1555 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADRLBMIJE4JXX6WCB335WBDXOIYZBANCNFSM6AAAAAAZPSIKDM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I've made all the changes suggested, with the exception of removing #include <pico/stdlib.h> which is required for the call to set_sys_clock_khz(). The doco file is full of CR/LF sequences, however you don't seem to care about these. All other changes have been restyled. |
Thanks, looks good now! I fixed some merge weirdness (had |
Thanks again! Know it was a long slog, but we do really appreciate the efforts! |
I think #1548 is still/again accidentally overwritten and should be restored |
Huh, did not notice that. Good catch! See #1582 . |
Sorry about the messy PR, I updated the arduino-pico board files after developing this and had to update some of your I2S.cpp code by hand.
Note also the change to setFrequency(long) - simply to match the documentation.
I'll add a PR for the doco later.
Main changes:
Add MCLK support - enabled by setting the MCLK pin.
Sample rate to MCLK multiplier can be independently set to multiples of 64.
Changing the setting of the PIO dividers from float mode to 16:8 mode and restricting the clock dividers to 16:0 only, so that MCLK can be reliably synchronised.
Add SYSCLK to sample rate optimisation - by changing the processor frequency.