SimpleTone I2S example, with pins specified #550
Replies: 5 comments 8 replies
-
@Andy2No why not submit a PR with your updated example? |
Beta Was this translation helpful? Give feedback.
-
@earlephilhower Mostly, because I have no idea how :) I've stuck to just being a consumer and beta tester, of github repositories. I suppose I ought to learn more about it, but I don't really know where to start. |
Beta Was this translation helpful? Give feedback.
-
I'm using a TDA1543. my program processes the signal in real time and generates a sample exactly every 40 microseconds (25KHz). I need to send that sample to the left channel (because it's mono) every time I calculate a new one, but don't waste any processing time in sending it. For now, to accomplish that, I'm dedicating the second core to make the submission to the DAC. Could I do the same with this library and leave the second core free? how? |
Beta Was this translation helpful? Give feedback.
-
@gabrieldeampli I only added some comments to it, but as I understand it, I2S.write() is a blocking operation so it doesn't return until it's completed. That's responsible for the bulk of the timing. I suspect that it gets delayed by interrupts, e.g. to update the millis() timer and handle USB, but I haven't checked with recent versions. It's a good enough example to see things are working but for any practical use, the method using buffers is probably the way to go. |
Beta Was this translation helpful? Give feedback.
-
Ah. I think I understand. The writing to the external device via I2S is done at specific times in a synchronous way, so I can't decide exactly when to send my sample. Even if the buffer is empty and I put a sample in it, it is not certain that it will be sent at that moment, but will wait for its turn to be sent. Is that so? |
Beta Was this translation helpful? Give feedback.
-
The SimpleTone example, for I2S doesn't document which pins are used, so it was necessary to look at the code to work that out. By default, it uses the only three pins that can be analogue inputs, which often wouldn't be what's wanted.
So, here is a very simple change to SimpleTone.ino, which I've verified with an Adafruit UDA1334A based I2S Stereo Decoder, moving the signals to different pins, and adding some comments to explain how to change them.
The I2S.setXXXX() lines must be placed before the I2S.begin().
Beta Was this translation helpful? Give feedback.
All reactions