I am having trouble configuring the McBSP on a DM3730 to interface with a codec (AD1938). I can't get the McBSP module to transmit any data.
The connections between the DM3730 and the codec are:
DM3730 Codec
McBSP3_CLKX <- BCLK
McBSP3_FSX <- LRCLK
McBSP3_DX -> DSDATA
McBSP3_DR <- ASDATA
(i.e. the McBSP is in slave mode, with bit and frame clocks generated by the codec)
I have tested the McBSP when configured in MASTER mode, and data then goes out McBSP3_DX, so I conclude that the pad configuration is correct. However, when I run it in SLAVE mode it does not transmit. A scope shows a 48 kHz phase clock input to _FSX and an approx 12.3 MHz bit clock going to _CLKX, which I expect with the codec's settings of 8 x 32-bit words/frame, 48kHz sampling rate. We are using a LogicPD DM3730 Torpedo development board for the testing.
My guess is that I'm missing something in the configuration registers. The values I'm setting presently (I've tried variations on many of them) are:
myMcBSP->spcr2 = 0x0300;
myMcBSP->spcr1 = 0x0010;
myMcBSP->rcr2 = 0x0001;
myMcBSP->rcr1 = 0x07A0;
myMcBSP->xcr2 = 0x00A1;
myMcBSP->xcr1 = 0x07A0;
myMcBSP->srgr2 = 0xb0ff;
myMcBSP->srgr1 = 0x0100;
myMcBSP->mcr2 = 0x00;
myMcBSP->mcr1 = 0x00;
myMcBSP->rcera = 0x0F;
myMcBSP->rcerb = 0x0F;
myMcBSP->xcera = 0xFF;
myMcBSP->xcerb = 0xFF;
myMcBSP->pcr = 0x058f;
myMcBSP->rcerc = 0x00;
myMcBSP->rcerd = 0x00;
myMcBSP->xcerc = 0x00;
myMcBSP->xcerd = 0x00;
myMcBSP->rcere = 0x00;
myMcBSP->rcerf = 0x00;
myMcBSP->xcere = 0x00;
myMcBSP->xcerf = 0x00;
myMcBSP->rcerg = 0x00;
myMcBSP->rcerh = 0x00;
myMcBSP->xcerg = 0x00;
myMcBSP->xcerh = 0x00;
myMcBSP->sysconfig = 0x08;
myMcBSP->thrsh2 = 0x00;
myMcBSP->thrsh1 = 0x00;
myMcBSP->irqenable = 0x00;
myMcBSP->wakeupen = 0x00;
myMcBSP->xccr = 0x1000;
myMcBSP->rccr = 0x0800;
myMcBSP->sselcr = 0x00;
[then after a delay I take the McBSP out of reset as follows]
myMcBSP->spcr1 |= (1 << 0);
myMcBSP->spcr2 |= ((1<<7) | (1<<6) | (1<<0) );
Probing the registers with JTAG while stepping through the code shows that:
- XBUFFSTAT (register 0x4902_40B4) starts off at 128 and decrements by one each time I write a new word to DXR, so it looks like the data is getting into the module's queue.
- IRQSTATUS (0x4902_40A0) reads 0x0000_0400 after the McBSP port has been initialized, but before trying to send any data. After running for a while, the value is 0x0000_1410, indicating that the Tx buffer has overflowed (because the test program is continually writing to DXR).
- SPCR2 (0x4902_4010) reads 0x0000_03C7. XEMPTY bit is set, so there is data in the Tx shift register.
- SPCR1 (0x4902_4014) reads 0x0000_0011. Interestingly, RRDY is *not* set, indicating that there is no data in the receiver despite the fact that codec data is being presented continuously on McBSP3_DR. This would perhaps suggest that the McBSP's clocking is not working.
I'll keep investigating, but in the meantime does anyone have any suggestions?
Thanks!
Bjarne