leeton I use four analog inputs (pin 0,1,2,3 on Audio Expander Capelet ), the corresponding time will be 4.2, 6.6, 12.5, 14.9 us?
no, they will be those corresponding to lines ADC0, ADC1, ADC2. ADC3: 1.2us, 4.2us, 12.5us, 14.9us.
If you edit the file ~/Bela/pru/pru_rtaudio.p
and you add the following lines (add those marked as +
, but don't include the +
itself!), then you will see the pins P8_45
, P8_46
, P8_43
, P8_44
turn on briefly for each of the following, respectively: DAC0/2, ADC0/2, DAC1/3, ADC1/3. Additionally, P8_41
will turn on just before DAC0, so you can distinguish each of the 0/2 and 1/3 pairs.
diff --git a/pru/pru_rtaudio.p b/pru/pru_rtaudio.p
index d739b5b..9668fe9 100644
--- a/pru/pru_rtaudio.p
+++ b/pru/pru_rtaudio.p
@@ -1051,8 +1051,10 @@ SPI_DAC_LOAD_DONE:
// QBBS MCASP_DAC_HIGH_WORD, r1, 1
QBBS MCASP_DAC_HIGH_WORD, reg_flags, FLAG_BIT_MCASP_HWORD
MCASP_DAC_LOW_WORD:
+SET R30.t4
// Load next 2 Audio DAC samples and store zero in their place
LBCO reg_mcasp_dac_data, C_MCASP_MEM, reg_mcasp_dac_current, 4
+CLR R30.t4
MOV r2, 0
SBCO r2, C_MCASP_MEM, reg_mcasp_dac_current, 4
ADD reg_mcasp_dac_current, reg_mcasp_dac_current, 4
@@ -1122,7 +1124,9 @@ QBBS SPI_SKIP_DAC_WRITE_0, reg_flags, FLAG_BIT_BELA_MINI
DAC_CHANNEL_REORDER r8, r1
LSL r8, r8, AD5668_ADDRESS_OFFSET
OR r7, r7, r8
+SET R30.t0
DAC_WRITE r7
+CLR R30.t0
SPI_SKIP_DAC_WRITE_0:
// Read ADC channels: result is always 2 commands behind
@@ -1136,7 +1140,9 @@ SPI_SKIP_DAC_WRITE_0:
MOV r7, AD7699_CFG_MASK
OR r7, r7, r8
+SET R30.t1
ADC_WRITE_GPIO r7, r7, r1
+CLR R30.t1
// Mask out only the relevant 16 bits and store in reg_adc_data
MOV r2, 0xFFFF
@@ -1155,7 +1161,9 @@ QBBS SPI_SKIP_DAC_WRITE_1, reg_flags, FLAG_BIT_BELA_MINI
OR r7, r7, r8
SPI_SKIP_DAC_WRITE_1:
// this DAC_WRITE should also be conditional to BELA_MINI, but if we do that, the ADC reads weird values. No idea why. Anyhow, we disabled the CS_ in DAC_WRITE
+SET R30.t2
DAC_WRITE r7
+CLR R30.t2
// Read ADC channels: result is always 2 commands behind
// Start by reading channel 2 (result is channel 0) and go
@@ -1166,7 +1174,9 @@ SPI_SKIP_DAC_WRITE_1:
LSL r8, r8, AD7699_CHANNEL_OFFSET
MOV r7, AD7699_CFG_MASK
OR r7, r7, r8
+SET R30.t3
ADC_WRITE r7, r7
+CLR R30.t3
// Move this result up to the 16 high bits
LSL r7, r7, 16
Please note that this hinders the functioning of the Bela multiplexer capelet, so make sure you undo these changes if you are planning on using it.