PT8211 working.
author"Darron Broad" <darron@kewl.org>
Tue, 07 Mar 2017 04:27:21 +0000
changeset 156 ab9c1b7b766e
parent 155 682463ea1fd6
child 157 292b6de5a24b
PT8211 working.

this chip needs a big bypass capacitor else the signal
is very distorted.

the I2S data-sheet says we need to set CKP here but the
chip data-sheet says it's forced to 1. not sure what
to do really ;-0)
src/pic32.c
src/pic32.h
--- a/src/pic32.c	Tue Mar 07 02:52:51 2017 +0000
+++ b/src/pic32.c	Tue Mar 07 04:27:21 2017 +0000
@@ -127,7 +127,13 @@
 	SPI1BRG = I2S_BRG;
 
 	/* SPI 1 AUDIO MODE */
-	SPI1CONbits.CKP = 1;		/* CLOCK POLARITY */
+#if DACTYPE == CS4334
+	SPI1CONbits.CKP = 1;            /* CLOCK POLARITY */
+#else
+	SPI1CONbits.CKP = 0;            /* CLOCK POLARITY */
+	SPI1CONbits.FRMPOL = 1;
+	SPI1CON2bits.AUDMOD = 1;	/* LEFT JUSTIFIED */
+#endif
 	SPI1CONbits.MSTEN = 1;		/* MASTER MODE */
 	SPI1CON2bits.AUDEN = 1;		/* AUDIO PROTOCOL ENABLED */
 
--- a/src/pic32.h	Tue Mar 07 02:52:51 2017 +0000
+++ b/src/pic32.h	Tue Mar 07 04:27:21 2017 +0000
@@ -22,6 +22,14 @@
 
 #define FCY (48000000UL)
 
+/*
+ * DAC TYPE
+ */
+#define CS4334 (1) /* I2S MODE */
+#define PT8211 (2) /* LEFT-JUSTIFIED MODE */
+
+#define DACTYPE (PT8211)
+
 #if 0
 /*
  * SAMPLE RATE  = 44100