Skip to content
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

EXTERNAL_AUDIO_OUTPUT not working on RP2040? #166

Closed
tomcombriat opened this issue Jan 31, 2023 · 7 comments
Closed

EXTERNAL_AUDIO_OUTPUT not working on RP2040? #166

tomcombriat opened this issue Jan 31, 2023 · 7 comments
Labels

Comments

@tomcombriat
Copy link
Collaborator

Apparently, according to: https://groups.google.com/g/mozzi-users/c/csMUSbZjnf8

Will try to reproduce.

@tomcombriat
Copy link
Collaborator Author

I confirm this bug, at least when trying to use I2S via an external audio output function.
Weird things:

  • an analogWrite in audioOutput seems to work (PWM frequency is to low thought), does not hang
  • putting the I2S output function in updateAudio works (but not clean as this function can be called in burst)
  • putting the I2S output function in a user defined audioOutput works for approx 0.5s, then makes weird signal (random) and then hang the whole chip. The weird signal actually looks like what we got when the conflict on IRQ with the I2S was not solved yet.
    I have to say that I really do not have any idea of why this is happening… Especially as the I2S (did not try SPI) works in updateAudio I kind of rule out an I2S problem, why putting it in audioOutput changes something?

Any idea?

@tfry-git
Copy link
Collaborator

So what you tested is essentially that you took the code for EXTERNAL_DAC_VIA_I2S but placed it in a custom audioOutput(), instead? And in that case is does not work? Weird.

One idea: Could it be that the speed of the I2S does not quite match the rate at which audioOutput() gets called? Perhaps the buffer is getting overcrowed, eventually resulting in a hang? If that is the issue, checking i2s.availableForWrite() should help.

@tomcombriat
Copy link
Collaborator Author

So what you tested is essentially that you took the code for EXTERNAL_DAC_VIA_I2S but placed it in a custom audioOutput(), instead? And in that case is does not work? Weird.

Yup.

I do not really care about getting it to work with I2S (as this is already implemented in "hardware") but there was a report of a similar problem on the forum with I2C, which triggered me to test the EXTERNAL_AUDIO_OUTPUT on RP2040 (did you try?).
That being said, I2C is usually too slow to sustain an AUDIO_RATE, so it might be the same problem. Will try one of these days with SPI emulating I2S (without buffer) to see if this error remains.

@tomcombriat
Copy link
Collaborator Author

Okay, using i2s.availableForWrite() as a crude test seems to work (with a few glitches because of the two buffers probably not running exactly at the same time, that is not an optimal situation).

So closing this for now.

@tfry-git
Copy link
Collaborator

tfry-git commented Feb 5, 2023

Ok, actually, I think setting BYPASS_MOZZI_OUTPUT_BUFFER is the "clean" way to go in this situation, then. That makes sense, too, as the whole trouble is that there already is another buffer at work.

@tomcombriat
Copy link
Collaborator Author

Yeah, but I think there is no need to have this work cleanly with I2S as it is ported already. This was just a mockup test to see if the EXTERNAL_AUDIO was working (and I had this DAC wired on my breadboard ;) ).

@tfry-git
Copy link
Collaborator

tfry-git commented Feb 5, 2023

Sure, I was just saying this for completeness (and because I had sort of forgotten that we already have a ready solution for dealing with the case of an independent output buffer somewhere).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants