Jump to content
  • 0

Pattern Generator to Generate I2S


Logan B

Question

After reading the documentation its not entirely clear what I can get out of the pattern generator.
 

I'd like to send custom messages via I2S and other protocols with the click of a button. For example, enter the data I want to send, and the device sends the specified data via the specified protocol automatically. Is this possible with the pattern generator on the Digital discovery device or any other devices?

 

Also I see the analog discovery 3 does not list I2S as a supported bus protocol. This seems odd as it is the more premium product than the digital discovery. Is this correct?

Edited by Logan B
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi Attila,

 

Even though I set I2S pattern in Logic of W/F, I could not make any pattern output.

So could you please share the project file for I2S pattern 1KHz sinewave @48KHz sample?

 

Thanks in advance.

Link to comment
Share on other sites

  • 0

Hi @plswelcomeroh

See the following:

image.png

For more samples use configuration with deeper Pattern device buffer. I2S rate will be frequency / 2 / bits_per_channel

const cbit = Patterns.Channels.DIO2.Samples.value;
const bps = 16;
const csample = cbit/bps/2;
var rgsel = [], rgdat = [];
print('bits:',cbit,' samples:',csample);
for(var j = 0; j < csample; j++){
    var v1 = round((1.0+sin(2.0*PI*j/csample))/2*(pow(2,16)-1));
    for(var i = bps-1; i >= 0; i--) rgdat.push((v1>>i)&1); // left
    for(var i = bps-1; i >= 0; i--) rgdat.push((v1>>i)&1); // right
    for(var i = 0; i < 2*bps; i++) rgsel.push(((i+1)%(2*bps))<bps?1:0);
}
Patterns.Channels.DIO2.custom = rgdat;
Patterns.Channels.DIO0.custom = rgsel;

 

Link to comment
Share on other sites

  • 0

Hi Attila,

Thank you for supporting it.

 

Is there any limitation on the PLL divider? what I mean is how do I set 12.288MHz for I2S?

And could you please share your project file?

 

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...