FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
6159 Discussions

How do I make a I2S transmitter on the DE0-Nano?

SFitz3
Beginner
964 Views

I am trying to transmit a square wave in I2S for the CS4334 DAC, but I do not understand the timing behind it. The code I have so far doze not work.

Music.v

module Music(input wire clk, output reg SDATA, output reg SCLK, output reg LRCK, output reg MCLK, output reg[7:0] debugs); reg[23:0] PCM[0:4]; initial begin $readmemh ("pcm.mem", PCM); end     reg[31:0] Mcounter; //Master Clock Counter reg[31:0] Scounter; //Serial Clock Counter reg[31:0] Lcounter; //Channel Counter always @ (posedge clk ) begin //50000000 hertz //Create MCLK if(Mcounter == 195) begin Mcounter <= 0; MCLK <= !MCLK; end else begin Mcounter <= Mcounter + 1; end //Create SCLK if(Scounter == 2083) begin Scounter <= 0; SCLK <= ~SCLK; end else begin Scounter <= Scounter + 1; end //Create LCLK if(Lcounter == 50000) begin Lcounter <= 0; LRCK <= ~LRCK; end else begin Lcounter <= Lcounter + 1; end end     reg[31:0] byte; reg[7:0] serialBit; reg[23:0] tmp; //Serial Signal Generator always @ (negedge SCLK) begin if(serialBit == 23) begin serialBit <= 0; if(byte == 4) begin byte <= 0; end else begin byte <= byte + 1; end end else begin serialBit <= serialBit; end SDATA <= ((tmp & (1 << serialBit)) >> serialBit); end   always @ (*) begin tmp = PCM[byte]; end endmodule

pcm.mem

FFFFFF FFFFFF 000000 000000

Is there any documentation about I2S.

Sorry if this question is posted in the incorrect spot because I did not know where to post it.

0 Kudos
3 Replies
EBERLAZARE_I_Intel
588 Views

Hi,

 

Are you trying to connect to the GPIO or the ADC of the DE0 Nano?

 

Regards.

0 Kudos
SFitz3
Beginner
588 Views

I am connecting to the GPIO

0 Kudos
EBERLAZARE_I_Intel
588 Views

Hi,

 

Have you assign the pins correctly?

 

If you are designin using Qsys/Platform Designer, make sure when you enable the GPIO's in the peripheral pins in Qsys/Platform Designer and that you update the Assignment editor page to include your linked pin.

 

i2s document to refer, De0 nano is using Cyclone V so you can refer:

https://rocketboards.org/foswiki/Projects/SodiaALSAaudioExampleDesign

 

Regards.

 

0 Kudos
Reply