CS8416 in Software Mode - diyAudio
Go Back   Home > Forums > Source & Line > Digital Line Level

Digital Line Level DACs, Digital Crossovers, Equalizers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 19th May 2011, 08:26 PM   #1
eehobby is offline eehobby  Canada
diyAudio Member
 
Join Date: Aug 2003
Location: Calgary
Default CS8416 in Software Mode

Is anyone here using the CS8416 in "Software Mode"?
If so, I have some questions.

I have built a DAC board with the CS8416 and the MAX9850. I have the I2C bus working nicely (connected to a PIC 18F2550) and I can read/write commands to either chip. But, so far - the only sound output is a few clicks.

Please share your init sequence. Here is mine (function I2C_W2 writes 2 bytes on the I2C bus):
Code:
r = I2C_W2(RXI2S_A, RXI2S_SADFMT, 0b10000000);	// set audio output port to Master mode
r = I2C_W2(RXI2S_A, I2SDAC_LRCLKH, 0b10001011);	// set Integer mode, DLY, 24 bit
r = I2C_W2(RXI2S_A, I2SDAC_DAUDIO, 0b00001000);	// set I2S data
r = I2C_W2(RXI2S_A, RXI2S_CNTRL2, 0b00000011);	// set GPO-0, red, to C bit
r = I2C_W2(RXI2S_A, RXI2S_CNTRL3, 0b01100000);	// set GPO-1, green, to NVERR

r = I2C_W2(RXI2S_A, RXI2S_CNTRL4, 0b10000000);	// set RUN
a) which of the 16 choices for GPOn best describes if the CS8416 is decoding a valid stream? I have tried the C (channel status) and NVERR, but they are always 0 (so far).

b) I have my CS8416 in Master Mode and the DAC in Slave Mode, does that make sense?

Thanks,
Jake
  Reply With Quote
Old 21st May 2011, 07:09 PM   #2
diyAudio Member
 
Join Date: Oct 2001
Location: .
a)AUDIO 1001 Non-audio indicator for decoded input stream.
In order to make the determination as to whether the data is audio (linear PCM) or non-audio (AC3/DTS) the data has to be valid.
  Reply With Quote
Old 22nd May 2011, 08:15 PM   #3
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
Default cs8416 init via SPI

You might want to do a cross check with (part of) my SPI init code.

This is confirmed to work (also by reading status registers, eg the receiver error (0C) register and the version register (7F).

Code:
int control4_reg = 0x8b; // 0x8b = coax 1 default, 0xb2 = coax 2, 0xba = coax 3, 0xa3 = opt1, 0xaa = opt2, 
 
void cs8416_init(void) {
 cs8416_rst = 0;     // put device in reset
 DelayMs(1);       // delay 1 ms
 cs8416_rst = 1;     // wake device
 DelayMs(1);       // delay 1 ms
 cs8416_cs = 1;     // enter SPI mode by setting cs high 
 cs8416_write(control4, control4_reg);   // send run state, RXP0 on, RXP2 (not connected on PCB) to TX
 
 cs8416_write(rem, 0xff);       // unmask all receiver error bits
 
 cs8416_write(int_mask, 0xff);       // unmask all IRQ
 
 cs8416_write(sadf, 0b10100101);  // set master mode (1)
                  // OSCLK is 64*Fs (0)
                  // 16-bit resolution (10)
                  // left-justified (0)
                  // MSB on second clock period (1)
                  // sampled on rising edges of OSCLK (0)
                  // right channel when OLRCK is high (1)
 
 
 cs8416_setpdur(1);
 
} //end cs8416_init
You might want to try reading the 7F register (should read 0b00101111 if you have a version E). First argument of the cs8416_write function is the register's friendly name (defined in include file, but you'll recognize from the datasheet).

Now, the trouble I am having is I am not getting anything useful out of the 0x19 - 0x22 (channel status registers, would love to read the sample rate, bit depth from the S/PDIF stream)... Can anyone help, please?
  Reply With Quote
Old 22nd May 2011, 08:18 PM   #4
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
Default and...

wrt b) yes, that configuration makes sense
  Reply With Quote
Old 28th May 2011, 02:24 PM   #5
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
Quote:
Originally Posted by Koen Smeets View Post
Now, the trouble I am having is I am not getting anything useful out of the 0x19 - 0x22 (channel status registers, would love to read the sample rate, bit depth from the S/PDIF stream)... Can anyone help, please?
To answer my own query: I managed to read the channel status registers. Problem turned out to be I have LSB/MSB mixed up. Bit depth, BTW, seems to be set to 24 bits all the time, at least in all the sources I have used so far (on board sound card, EMU0404PCIE card...)

Cheers!!
  Reply With Quote
Old 28th May 2011, 04:00 PM   #6
eehobby is offline eehobby  Canada
diyAudio Member
 
Join Date: Aug 2003
Location: Calgary
Quote:
Originally Posted by Koen Smeets View Post

Code:
 
cs8416_write(sadf, 0b10100101);  // set master mode (1)
                  // OSCLK is 64*Fs (0)
                  // 16-bit resolution (10)
                  // left-justified (0)
                  // MSB on second clock period (1)
                  // sampled on rising edges of OSCLK (0)
                  // right channel when OLRCK is high (1)
 
 
 cs8416_setpdur(1);
Thanks for the example. Can you offer any insight on how you choose those init values;
Why MSB on second clock period?
Why right channel on ...?

Also, what does CS8416_setpdur(1) do?


Quote:
Originally Posted by Koen Smeets View Post
You might want to try reading the 7F register (should read 0b00101111 if you have a version E).
When I read register 7F, I do indeed get 0x2F.

Jake
  Reply With Quote
Old 28th May 2011, 04:56 PM   #7
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
Quote:
Originally Posted by eehobby View Post
Thanks for the example. Can you offer any insight on how you choose those init values;
Why MSB on second clock period?
Why right channel on ...?

Also, what does CS8416_setpdur(1) do?



When I read register 7F, I do indeed get 0x2F.

Jake
Init values are mostly as per I2S bus specs / datasheet of your DAC IC. I believe you are also configured to use I2S, so possibly you should stick to the init values I have?

CS8416_setpdur(1) sets the PDUR bit. For the functionality of the PDUR bit, please search the datasheet of the CS8416. I can't explain it any better than that.
  Reply With Quote
Old 28th May 2011, 09:03 PM   #8
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
One more thing that came to mind: I had a situation where my CPU stalled (because of table writes to program memory), effectively violating SPI timing. Result was skipping inputs when cycling through RXP0 - RXP5.

Do post how you are progressing with troubleshooting.
  Reply With Quote
Old 28th May 2011, 09:29 PM   #9
eehobby is offline eehobby  Canada
diyAudio Member
 
Join Date: Aug 2003
Location: Calgary
I have made some progress and got something out of my DAC. The sound is distorted, but recognizable.

Meanwhile I still can't get the GPO LEDs to change. For example the AUDIO bit should be high when a proper SPDIF/PCM stream is detected, but it stays low all the time (although it does flicker a bit when I disconnect the SPDIF input).
  Reply With Quote
Old 29th May 2011, 06:18 AM   #10
diyAudio Member
 
Join Date: Apr 2010
Send a message via Skype™ to Koen Smeets
Quote:
Originally Posted by eehobby View Post
... For example the AUDIO bit should be high when a proper SPDIF/PCM stream is detected, ...
Are you sure? Datasheet says about the !AUDIO pin 15 in hardware mode "When low, a valid linear PCM audio stream is indicated." (an exclamation mark in front of or a 'overlined' pinnname is an active low indicator)

So when valid PCM is detected pin is low, not high. Still doesn't explain the flickering when you disconnect input, though, LED should be solid on. Time to check the electrical connections, then? Or maybe resetting the part in some while loop?...

Good luck!
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CS8416 in sw slave mode with external clock milandks Digital Line Level 0 29th March 2009 09:45 PM
Help me set up CS8416 in HW mode ezkcdude Digital Source 6 2nd May 2006 10:08 PM
Using a spdt switch to select between triode mode and pentode mode on a guitar amp. G Tubes / Valves 19 15th March 2006 09:15 AM
Calculating watt requirements for multi-mode/tri-mode operation? Datoyminaytah Solid State 1 14th August 2004 07:43 AM
DF1706 and software mode control? WTS Digital Source 8 25th March 2004 10:02 PM


New To Site? Need Help?

All times are GMT. The time now is 12:51 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2