diff pru_rtaudio.p @ 100:b697e82ebb25

PRU now checks for McASP underrun and resets if detects it.
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 27 Jul 2015 12:44:55 +0100
parents 472e892c6e41
children 31ca45939a0c
line wrap: on
line diff
--- a/pru_rtaudio.p	Mon Jul 27 11:33:08 2015 +0100
+++ b/pru_rtaudio.p	Mon Jul 27 12:44:55 2015 +0100
@@ -145,6 +145,7 @@
 #define MCASP_RFIFOCTL			0x1008
 #define MCASP_RFIFOSTS			0x100C
 
+#define MCASP_XSTAT_XUNDRN_BIT          0        // Bit to test if there was an underrun
 #define MCASP_XSTAT_XDATA_BIT           5        // Bit to test for transmit ready
 #define MCASP_RSTAT_RDATA_BIT           5        // Bit to test for receive ready 
 	
@@ -853,6 +854,7 @@
       // Wait for McASP XSTAT[XDATA] to set indicating we can write more data
 MCASP_WAIT_XSTAT:
       LBBO r2, reg_mcasp_addr, MCASP_XSTAT, 4
+      QBBS START, r2, MCASP_XSTAT_XUNDRN_BIT // if underrun occurred, reset the PRU
       QBBC MCASP_WAIT_XSTAT, r2, MCASP_XSTAT_XDATA_BIT
 
       MCASP_REG_WRITE_EXT MCASP_XBUF, r7