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.
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
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.
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: