DSPRelated.com
Forums

EDMA transfer problem on C6711

Started by bg_ie August 31, 2003
Hi,

I was wondering if you could help me sort out a problem I'm having
with my EDMA transfer. I'm working with the C6711DSK and the AIC23EVM
Codec.

The problem is that when I use EDMA transfering, I'm losing every
second input and output sample. I have the sample rate set as
88200Hz, but when I output a 1k signal, I get a 500Hz signal. When I
input a 1kHz signal to the codec, I get 500 samples per cycle.

The problem is not related to the McBSP becuase I dont lose any
samples when I pole, instead of the EDMA transfer.

The AIC23 accepts the right and left channel as a 32 bit frame. In
otherwords the left and right channels are 16 bits each.

Another think I've noticed is that the right channel is clipped. If 1
output a signal with the maximum possible applitude, 1 Volts RMS, it
is clipped somewhere above and below 1 and -1 volts respectfully.
This does not happen to the left channel, and does not happen to
either channel when I use polling instead of EDMA transferring.

This is how I'm setting up the EDMA -

/* Config Structures */
EDMA_Config DSS_edmaMcbspRx = {
0x207D0000, /* Option */
0x30000000, /* Source Address - Numeric */
0x00000000, /* Transfer Counter - Numeric */
0x00000000, /* Destination Address - Numeric */
0x00000002, /* Index register - Numeric */
0x00000000 /* Element Count Reload and Link Address */
};

EDMA_Config DSS_edmaMcbspTx = {
0x431C0000, /* Option */
0x00000000, /* Source Address - Numeric */
0x00000000, /* Transfer Counter - Numeric */
0x30000000, /* Destination Address - Numeric */
0x00000002, /* Index register - Numeric */
0x00000000 /* Element Count Reload and Link Address */
};

I think the best thing is if I link to the code I'm using (.txt
= .c) -

http://baz.perlmonk.org/main.txt - contains main
http://baz.perlmonk.org/dss.txt - pipe interface to the serial port
audio
http://baz.perlmonk.org/dss_dsk6711.txt
http://baz.perlmonk.org/dss_edmacisr.txt - EDMA ISR

the cdb file -

http://baz.perlmonk.org/audio.cdb

The AIC23 Codec uses MCBSP 1 for control and MCBSP 0 for data
transfer. I've tried setting differenct sample rates on the AIC23,
but the EDMA transfer always seems to half my number of samples.

Can anyone see what I'm doing wrong, I've been stuck at this for a
while and I'd really like to get it fixed. Thanks for your help.

Barry.

When polling, I output a sine wave with the following -

for(i=0;i<80;i++)
sig[i] = cos(w(1102.5)*i/(Float)(SR));

EDMA_RSET(EER, 0x0000); /* Disable all events */
EDMA_RSET(ECR, 0xffff); /* Clear all pending events */
EDMA_RSET(CIER, 0x0000); /* Disable all events to Interrupt */
EDMA_RSET(CIPR, 0xffff); /* Clear all pending Queued EDMA ints */ MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02001000);
MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C01000);
MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C11000);

MCBSP_RSETH(DSS_hMcbsp0, SPCR, 0x02010001);

initRegs(); for(;;)
for(i=0;i<80;i++)
{

f1=sig[i];
f2=sig[i];

t1 = f1 * div;
t1 &= 0xffff;

t2 = f2 * div;
t2 &= 0xffff;

t2 <<= 16;
t1 = t1 | t2;

spWrite(DSS_hMcbsp0, t1);
t1 = spRead(DSS_hMcbsp0);
/* t2 = (t1>>16) & 0xffff;
t1 = t1 &0xffff;

if(t1 & 0x8000)
t1 |= 0xFFFF0000;

if(t2 & 0x8000)
t2 |= 0xFFFF0000;

f1 = (((Float)((Int)(t1)))/div);
f2 = (((Float)((Int)(t2)))/div);*/

}
}

Uns spRead(MCBSP_Handle hMcBsp)
{

// Poll until new value ready to read
while (((MCBSP_RGETH(DSS_hMcbsp0, SPCR)) & 0x2) == 0);

return MCBSP_read(hMcBsp);
}

// Write from McBsp to AIC23
Void spWrite(MCBSP_Handle hMcBsp, Uns data)
{

// Poll until ready to transmit
while (( (MCBSP_RGETH(hMcBsp, SPCR)) & 0x20000) == 0);

MCBSP_write(hMcBsp,data);
}




This sounds eirily like an issue with the PCM3003 a couple of weeks ago.  Check out the message below- it may be a documentation issue.

mikedunn




bg_ie <b...@yahoo.com> wrote:
Hi,

I was wondering if you could help me sort out a problem I'm having
with my EDMA transfer. I'm working with the C6711DSK and the AIC23EVM
Codec.

The problem is that when I use EDMA transfering, I'm losing every
second input and output sample. I have the sample rate set as
88200Hz, but when I output a 1k signal, I get a 500Hz signal. When I
input a 1kHz signal to the codec, I get 500 samples per cycle.

The problem is not related to the McBSP becuase I dont lose any
samples when I pole, instead of the EDMA transfer.

The AIC23 accepts the right and left channel as a 32 bit frame. In
otherwords the left and right channels are 16 bits each.

Another think I've noticed is that the right channel is clipped. If 1
output a signal with the maximum possible applitude, 1 Volts RMS, it
is clipped somewhere above and below 1 and -1 volts respectfully.
This does not happen to the left channel, and does not happen to
either channel when I use polling instead of EDMA transferring.

This is how I'm setting up the EDMA -

/* Config Structures */
EDMA_Config DSS_edmaMcbspRx = {
0x207D0000, /* Option */
0x30000000, /* Source Address - Numeric */
0x00000000, /* Transfer Counter - Numeric */
0x00000000, /* Destination Address - Numeric */
0x00000002, /* Index register - Numeric */
0x00000000 /* Element Count Reload and Link Address */
};

EDMA_Config DSS_edmaMcbspTx = {
0x431C0000, /* Option */
0x00000000, /* Source Address - Numeric */
0x00000000, /* Transfer Counter - Numeric */
0x30000000, /* Destination Address - Numeric */
0x00000002, /* Index register - Numeric */
0x00000000 /* Element Count Reload and Link Address */
};

I think the best thing is if I link to the code I'm using (.txt
= .c) -

http://baz.perlmonk.org/main.txt - contains main
http://baz.perlmonk.org/dss.txt - pipe interface to the serial port
audio
http://baz.perlmonk.org/dss_dsk6711.txt
http://baz.perlmonk.org/dss_edmacisr.txt - EDMA ISR

the cdb file -

http://baz.perlmonk.org/audio.cdb

The AIC23 Codec uses MCBSP 1 for control and MCBSP 0 for data
transfer. I've tried setting differenct sample rates on the AIC23,
but the EDMA transfer always seems to half my number of samples.

Can anyone see what I'm doing wrong, I've been stuck at this for a
while and I'd really like to get it fixed. Thanks for your help.

Barry.

When polling, I output a sine wave with the following -

for(i=0;i<80;i++)
sig[i] = cos(w(1102.5)*i/(Float)(SR));

EDMA_RSET(EER, 0x0000); /* Disable all events */
EDMA_RSET(ECR, 0xffff); /* Clear all pending events */
EDMA_RSET(CIER, 0x0000); /* Disable all events to Interrupt */
EDMA_RSET(CIPR, 0xffff); /* Clear all pending Queued EDMA ints */MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02001000);
MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C01000);
MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C11000);

MCBSP_RSETH(DSS_hMcbsp0, SPCR, 0x02010001);

initRegs();for(;;)
for(i=0;i<80;i++)
{

f1=sig[i];
f2=sig[i];

t1 = f1 * div;
t1 &= 0xffff;

t2 = f2 * div;
t2 &= 0xffff;

t2 <<= 16;
t1 = t1 | t2;

spWrite(DSS_hMcbsp0, t1);
t1 = spRead(DSS_hMcbsp0);
/* t2 = (t1>>16) & 0xffff;
t1 = t1 &0xffff;

if(t1 & 0x8000)
t1 |= 0xFFFF0000;

if(t2 & 0x8000)
t2 |= 0xFFFF0000;

f1 = (((Float)((Int)(t1)))/div);
f2 = (((Float)((Int)(t2)))/div);*/

}
}

Uns spRead(MCBSP_Handle hMcBsp)
{

// Poll until new value ready to read
while (((MCBSP_RGETH(DSS_hMcbsp0, SPCR)) & 0x2) == 0);

return MCBSP_read(hMcBsp);
}

// Write from McBsp to AIC23
Void spWrite(MCBSP_Handle hMcBsp, Uns data)
{

// Poll until ready to transmit
while (( (MCBSP_RGETH(hMcBsp, SPCR)) & 0x20000) == 0);

MCBSP_write(hMcBsp,data);
}

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join: Send an email to c...@yahoogroups.com

To Post: Send an email to c...@yahoogroups.com

To Leave: Send an email to c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/c6x

Other Groups: http://www.dsprelated.com




I'm not sure if this is the problem - when I poll the McBSPs I get
the correct sample rate. I think the problem is to do with the EDMA
transfer.

Any suggestions as to the exact problem?

Thanks,

Barry.

--- In , Mike Dunn <mike-dunn@s...> wrote:
>
> This sounds eirily like an issue with the PCM3003 a couple of weeks
ago. Check out the message below- it may be a documentation issue.
>
> mikedunn
>
> --- jaleitao2003 <jaleitao@c...> wrote:> How can I get 48 kHz then?
hi, sorry it took me so long - just had other stuff inthe queue ;-)
anyway - about getting 48kHz from your PCM3003... thesolution is much
simpler than you think... do you have that ADC.zip file downloaded
from TI'sFTP?well - inside you'll find the file:Audio Daughter Card
Users Guide.docthat file is a little misleading ;-) (thanks TI!!!)
don't even ask me how much time I spent reading theMcBSP specs and
trying to set it to read 48kHz!!! buthey - as the say - if all
possibilities fail - readthe manual...on page 4/5 there is this
jumper descriptions section- there is a table with J11/J12 settings -
the defaultboard setting is marked (lower right cell) - well -
fclk/512 does not equal 48kHz as it states -12288/512$!!! so - in
order to get "real 48kHz" -you have to play with the juumpers and put
J11 to pins3-4 and J12 to pins 1-2...good luck...
> bg_ie <bg_ie@y...> wrote:Hi,
>
> I was wondering if you could help me sort out a problem I'm having
> with my EDMA transfer. I'm working with the C6711DSK and the
AIC23EVM
> Codec.
>
> The problem is that when I use EDMA transfering, I'm losing every
> second input and output sample. I have the sample rate set as
> 88200Hz, but when I output a 1k signal, I get a 500Hz signal. When
I
> input a 1kHz signal to the codec, I get 500 samples per cycle.
>
> The problem is not related to the McBSP becuase I dont lose any
> samples when I pole, instead of the EDMA transfer.
>
> The AIC23 accepts the right and left channel as a 32 bit frame. In
> otherwords the left and right channels are 16 bits each.
>
> Another think I've noticed is that the right channel is clipped. If
1
> output a signal with the maximum possible applitude, 1 Volts RMS,
it
> is clipped somewhere above and below 1 and -1 volts respectfully.
> This does not happen to the left channel, and does not happen to
> either channel when I use polling instead of EDMA transferring.
>
> This is how I'm setting up the EDMA -
>
> /* Config Structures */
> EDMA_Config DSS_edmaMcbspRx = {
> 0x207D0000, /* Option */
> 0x30000000, /* Source Address - Numeric */
> 0x00000000, /* Transfer Counter - Numeric */
> 0x00000000, /* Destination Address - Numeric */
> 0x00000002, /* Index register - Numeric */
> 0x00000000 /* Element Count Reload and Link Address */
> };
>
> EDMA_Config DSS_edmaMcbspTx = {
> 0x431C0000, /* Option */
> 0x00000000, /* Source Address - Numeric */
> 0x00000000, /* Transfer Counter - Numeric */
> 0x30000000, /* Destination Address - Numeric */
> 0x00000002, /* Index register - Numeric */
> 0x00000000 /* Element Count Reload and Link Address */
> };
>
> I think the best thing is if I link to the code I'm using (.txt
> = .c) -
>
> http://baz.perlmonk.org/main.txt - contains main
> http://baz.perlmonk.org/dss.txt - pipe interface to the serial port
> audio
> http://baz.perlmonk.org/dss_dsk6711.txt
> http://baz.perlmonk.org/dss_edmacisr.txt - EDMA ISR
>
> the cdb file -
>
> http://baz.perlmonk.org/audio.cdb
>
> The AIC23 Codec uses MCBSP 1 for control and MCBSP 0 for data
> transfer. I've tried setting differenct sample rates on the AIC23,
> but the EDMA transfer always seems to half my number of samples.
>
> Can anyone see what I'm doing wrong, I've been stuck at this for a
> while and I'd really like to get it fixed. Thanks for your help.
>
> Barry.
>
> When polling, I output a sine wave with the following -
>
> for(i=0;i<80;i++)
> sig[i] = cos(w(1102.5)*i/(Float)(SR));
>
> EDMA_RSET(EER, 0x0000); /* Disable all events */
> EDMA_RSET(ECR, 0xffff); /* Clear all pending events */
> EDMA_RSET(CIER, 0x0000); /* Disable all events to Interrupt */
> EDMA_RSET(CIPR, 0xffff); /* Clear all pending Queued EDMA ints */ > MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02001000);
> MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C01000);
> MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C11000);
>
> MCBSP_RSETH(DSS_hMcbsp0, SPCR, 0x02010001);
>
> initRegs(); > for(;;)
> for(i=0;i<80;i++)
> {
>
> f1=sig[i];
> f2=sig[i];
>
> t1 = f1 * div;
> t1 &= 0xffff;
>
> t2 = f2 * div;
> t2 &= 0xffff;
>
> t2 <<= 16;
> t1 = t1 | t2;
>
> spWrite(DSS_hMcbsp0, t1);
> t1 = spRead(DSS_hMcbsp0);
> /* t2 = (t1>>16) & 0xffff;
> t1 = t1 &0xffff;
>
> if(t1 & 0x8000)
> t1 |= 0xFFFF0000;
>
> if(t2 & 0x8000)
> t2 |= 0xFFFF0000;
>
> f1 = (((Float)((Int)(t1)))/div);
> f2 = (((Float)((Int)(t2)))/div);*/
>
> }
> }
>
> Uns spRead(MCBSP_Handle hMcBsp)
> {
>
> // Poll until new value ready to read
> while (((MCBSP_RGETH(DSS_hMcbsp0, SPCR)) & 0x2) == 0);
>
> return MCBSP_read(hMcBsp);
> }
>
> // Write from McBsp to AIC23
> Void spWrite(MCBSP_Handle hMcBsp, Uns data)
> {
>
> // Poll until ready to transmit
> while (( (MCBSP_RGETH(hMcBsp, SPCR)) & 0x20000) == 0);
>
> MCBSP_write(hMcBsp,data);
> } >
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the
author of this message will receive your answer. You need to do
a "reply all" if you want your answer to be distributed to the entire
group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://www.yahoogroups.com/group/c6x
>
> Other Groups: http://www.dsprelated.com > ">http://docs.yahoo.com/info/terms/


Hi,

I'm still having issues with the above. I have managed to sort out the
clipping problem which was due to the fact that the codec was in
de-empishasis mode. This mode doesn't seem to function sensibly at
88.2kHz.

The AIC23EVM allows a number of sample rates, but each time I select
one I actually get half the required number of samples (for both the
dacs and adcs). In otherwords, if I set the codec for 88.2kHz, I
actually get 44.1kHz etc. This problem is related to either the edma
transfer or the pipe transfer. The reason I am sure of this is that
when I poll the values in McBSP's SPCR registers, instead of using
EDMA and PIPs, I get the correct sample rate. This is how I poll -

Uns spRead(MCBSP_Handle hMcBsp)
{

// Poll until new value ready to read
while (((MCBSP_RGETH(DSS_hMcbsp0, SPCR)) & 0x2) == 0);
return MCBSP_read(hMcBsp);
}

Void spWrite(MCBSP_Handle hMcBsp, Uns data)
{

// Poll until ready to transmit
while (( (MCBSP_RGETH(hMcBsp, SPCR)) & 0x20000) == 0);
MCBSP_write(hMcBsp,data);
}

for(;;)
{
spWrite(DSS_hMcbsp0, sampleOut);
sampleIn = spRead(DSS_hMcbsp0);
}

The code above allows me to work at the correct sample rate, but I can
alter this code and half my sample rate by doing two consecutive read
and/or two consecutive writes, for example -

for(;;)
{
spWrite(DSS_hMcbsp0, sampleOut);
spWrite(DSS_hMcbsp0, sampleOut);
sampleIn = spRead(DSS_hMcbsp0);
sampleIn = spRead(DSS_hMcbsp0);
}

Could this be the issue I'm having with my EDMA/PIP?

I've my EDMA set up to read from sourse address 0x00000000 when
transmitting, and to write to destination address 0x00000000 when
receiving. My EIX is 2.

My EDMA ISR is as follows - Void DSS_edmaIsr(Void)
{
Int channel = EDMA_RGET(CIPR); /* get Channel Interrupt Pending
bits */

if (channel & DSS_RXDONE) { /* Channel = McBSP Buffer Rx'ed */
PIP_put(&DSS_rxPipe);
DSS_rxCnt = 0; /* Reset Buffer Count for sync */

EDMA_RSET(CIPR, DSS_RXDONE); /* Reset EDMA Channel Flag */
DSS_rxPrime(TRUE);
}

if (channel & DSS_TXDONE) { /* Channel = McBSP Buffer Tx'ed */
PIP_free(&DSS_txPipe);
DSS_txCnt = 0; /* Reset Buffer Count for sync */

EDMA_RSET(CIPR, DSS_TXDONE); /* Reset EDMA Channel Flag */
DSS_txPrime(TRUE);
}
}

How might I debug the above? That is, how might I check at this stage,
before I do any PIPing, that I have recieved the correct number of
samples? How do I check my destination address, 0x00000000, when
receiving. Watches wont work due to caching.

Thanks for your help,

Barry. --- In , "bg_ie" <bg_ie@y...> wrote:
> Hi,
>
> I was wondering if you could help me sort out a problem I'm having
> with my EDMA transfer. I'm working with the C6711DSK and the
AIC23EVM
> Codec.
>
> The problem is that when I use EDMA transfering, I'm losing every
> second input and output sample. I have the sample rate set as
> 88200Hz, but when I output a 1k signal, I get a 500Hz signal. When
I
> input a 1kHz signal to the codec, I get 500 samples per cycle.
>
> The problem is not related to the McBSP becuase I dont lose any
> samples when I pole, instead of the EDMA transfer.
>
> The AIC23 accepts the right and left channel as a 32 bit frame. In
> otherwords the left and right channels are 16 bits each.
>
> Another think I've noticed is that the right channel is clipped. If
1
> output a signal with the maximum possible applitude, 1 Volts RMS,
it
> is clipped somewhere above and below 1 and -1 volts respectfully.
> This does not happen to the left channel, and does not happen to
> either channel when I use polling instead of EDMA transferring.
>
> This is how I'm setting up the EDMA -
>
> /* Config Structures */
> EDMA_Config DSS_edmaMcbspRx = {
> 0x207D0000, /* Option */
> 0x30000000, /* Source Address - Numeric */
> 0x00000000, /* Transfer Counter - Numeric */
> 0x00000000, /* Destination Address - Numeric */
> 0x00000002, /* Index register - Numeric */
> 0x00000000 /* Element Count Reload and Link Address */
> };
>
> EDMA_Config DSS_edmaMcbspTx = {
> 0x431C0000, /* Option */
> 0x00000000, /* Source Address - Numeric */
> 0x00000000, /* Transfer Counter - Numeric */
> 0x30000000, /* Destination Address - Numeric */
> 0x00000002, /* Index register - Numeric */
> 0x00000000 /* Element Count Reload and Link Address */
> };
>
> I think the best thing is if I link to the code I'm using (.txt
> = .c) -
>
> http://baz.perlmonk.org/main.txt - contains main
> http://baz.perlmonk.org/dss.txt - pipe interface to the serial
port
> audio
> http://baz.perlmonk.org/dss_dsk6711.txt
> http://baz.perlmonk.org/dss_edmacisr.txt - EDMA ISR
>
> the cdb file -
>
> http://baz.perlmonk.org/audio.cdb
>
> The AIC23 Codec uses MCBSP 1 for control and MCBSP 0 for data
> transfer. I've tried setting differenct sample rates on the AIC23,
> but the EDMA transfer always seems to half my number of samples.
>
> Can anyone see what I'm doing wrong, I've been stuck at this for a
> while and I'd really like to get it fixed. Thanks for your help.
>
> Barry.
>
> When polling, I output a sine wave with the following -
>
> for(i=0;i<80;i++)
> sig[i] = cos(w(1102.5)*i/(Float)(SR));
>
> EDMA_RSET(EER, 0x0000); /* Disable all events */
> EDMA_RSET(ECR, 0xffff); /* Clear all pending events */
> EDMA_RSET(CIER, 0x0000); /* Disable all events to Interrupt */
> EDMA_RSET(CIPR, 0xffff); /* Clear all pending Queued EDMA ints
*/
>
>
> MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02001000);
> MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C01000);
> MCBSP_RSETH(DSS_hMcbsp1, SPCR, 0x02C11000);
>
> MCBSP_RSETH(DSS_hMcbsp0, SPCR, 0x02010001);
>
> initRegs(); > for(;;)
> for(i=0;i<80;i++)
> {
>
> f1=sig[i];
> f2=sig[i];
>
> t1 = f1 * div;
> t1 &= 0xffff;
>
> t2 = f2 * div;
> t2 &= 0xffff;
>
> t2 <<= 16;
> t1 = t1 | t2;
>
> spWrite(DSS_hMcbsp0, t1);
> t1 = spRead(DSS_hMcbsp0);
> /* t2 = (t1>>16) & 0xffff;
> t1 = t1 &0xffff;
>
> if(t1 & 0x8000)
> t1 |= 0xFFFF0000;
>
> if(t2 & 0x8000)
> t2 |= 0xFFFF0000;
>
> f1 = (((Float)((Int)(t1)))/div);
> f2 = (((Float)((Int)(t2)))/div);*/
>
> }
> }
>
> Uns spRead(MCBSP_Handle hMcBsp)
> {
>
> // Poll until new value ready to read
> while (((MCBSP_RGETH(DSS_hMcbsp0, SPCR)) & 0x2) == 0);
>
> return MCBSP_read(hMcBsp);
> }
>
> // Write from McBsp to AIC23
> Void spWrite(MCBSP_Handle hMcBsp, Uns data)
> {
>
> // Poll until ready to transmit
> while (( (MCBSP_RGETH(hMcBsp, SPCR)) & 0x20000) == 0);
>
> MCBSP_write(hMcBsp,data);
> }