hello,everyone,nowadays i am doing experiments on McBSP of 6416,but i find the
'xrdy'and 'rrdy' in SPCR of McBSP are not woking as what
described in spru401(TMS320C6000 DSP Multichannel Buffered Serial Port (McBSP)
),they seems behavior strangly!below is my source code,dose anybody encounter
the same problem?
/*
examples:1.set CPUclk/256 as the clk for McBSP's SRGR,and generate the
CLKR.CLKX
and FSR.FSX for the McBSP0,then output them on CLKR.CLKX and FSR.
FSX pins.
2.store every word(32bits) received via McBSP0 to address from
0x00050000 by EDMA.
3.data on DR0 pin is coming from McBSP0's DX0,so DX0 are connected to
DR0 externally.
author: Wangke
date: 2008.03.15
*/
#include "McBSP.h"
#include
#include
#include
#include
MCBSP_Config mcbspconfig{
0x00000000, /* spcr ..*/
0x000400a0, /* rcr ..*/
0x000400a0, /* xcr ..*/
0x301f03ff, /* srgr ..*/
0x00000000, /* mcr ..*/
0x00000000, /* rcere0 */
0x00000000, /* rcere1 */
0x00000000, /* rcere2 */
0x00000000, /* rcere3 */
0x00000000, /* xcere0 */
0x00000000, /* xcere1 */
0x00000000, /* xcere2 */
0x00000000, /* xcere3 */
0x00000f00 /* pcr ..*/
};
EDMA_Config edmaconfig{
0x40200000, /* opt */
0x30000000, /* src */
0x00000010, /* cnt */
0x00050000, /* dst */
0x00000000, /* idx */
0x00100000 /* rld */
};
void delay(unsigned int cnt)
{
unsigned int j;
while(cnt>0)
{
for(j=0xff;j>0;j--);
cnt--;
}
}
int main(void)
{
EDMA_Handle edmahd;
MCBSP_Handle mcbsphd;
unsigned int dat=0,temp;
CSL_init();
EDMA_resetAll();
edmahd= EDMA_open(EDMA_CHA_REVT0,EDMA_OPEN_RESET);
if(edmahd == (EDMA_Handle)INV)
printf("EDMA_CHA_REVT0 opening is failure!\n");
else
{
EDMA_config(edmahd,&edmaconfig);
EDMA_enableChannel(edmahd);
/*
int i;
for(i=0;i<10;i++)
EDMA_setChannel(edmahd);
*/
}
mcbsphd=MCBSP_open(MCBSP_DEV0,MCBSP_OPEN_RESET);
if(mcbsphd == (MCBSP_Handle)INV)
printf("MCBSP_DEV0 opening is failure!\n");
else
{
MCBSP_reset(mcbsphd);
MCBSP_config(mcbsphd,&mcbspconfig);
MCBSP_start(mcbsphd,MCBSP_XMIT_START |
MCBSP_RCV_START |
MCBSP_SRGR_START |
MCBSP_SRGR_FRAMESYNC,
0x00003000);
//please compare the two while LOOP.
/*
while(1)
{
//data from DX0 is 2、4、6...,so the synchronization is not working well.
dat++;
temp&0x0000ffff;
temp=temp|0x0ff00000;
while(!MCBSP_xrdy(mcbsphd));
MCBSP_write(mcbsphd,temp);
}
*/
/*
while(1)
{
//data from DX0 is 1、2、3...,so the synchronization is working well.
dat++;
temp&0x0000ffff;
temp=temp|0x0ff00000;
while(!MCBSP_xrdy(mcbsphd));
MCBSP_write(mcbsphd,temp);
MCBSP_write(mcbsphd,temp);
}
*/
/*
while(1)
{
//data from DX0 is 1、2、3...,so the synchronization is working well.
dat++;
temp & 0x0000ffff;
temp=temp | 0x0ff00000;
while(!MCBSP_xrdy(mcbsphd));
while(!MCBSP_xrdy(mcbsphd));
MCBSP_write(mcbsphd,temp);
}
*/
/*
while(1)
{
//data from DX0 is 1、2、3...,so the synchronization is working well.
dat++;
temp & 0x0000ffff;
temp=temp | 0x0ff00000;
while(!(HSPCR0 & XRDYMASK));
while(!(HSPCR0 & XRDYMASK));
MCBSP_write(mcbsphd,temp);
}
*/
/*
while(1)
{
//data from DX0 is 1、3、5...,so the synchronization is working well.
dat++;
temp & 0x0000ffff;
temp=temp | 0x0ff00000;
while(!(HSPCR0 & XRDYMASK));
MCBSP_write(mcbsphd,temp);
MCBSP_write(mcbsphd,temp);
}
*/
while(1)
{
dat++;
temp & 0x0000ffff;
temp=temp | 0x0ff00000;
while(!(HSPCR0 & XRDYMASK));
//delay(2)--->data from DX0 is 1,3,5,7,9.B,D,F...,so the synchronization is not
working well.
//delay(6)--->data from DX0 is 0,2,3,5,6,8,9,B,C,E,F...,so the synchronization
is not working well.
//delay(8)--->data from DX0 is 0,1,3,4,5,7,8,9,B,C,D,F...,so the synchronization
is not working well.
//delay(10)--->data from DX0 is0,1,2,3,4,5,6,7,8,9,A,B,C...,so the
synchronization is working well.
//delay(32)--->data from DX0 is0,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5...,so the
synchronization is working well.
delay(10);
MCBSP_write(mcbsphd,temp);
}
MCBSP_close(mcbsphd);
}
}
of course,sending data via mcbsp0 in the EDMA mode,which i have tested,do its
work well,but i am really puzled that why the polling is not working as what i
expected all the time,it is a bug in 6416,or i have made a mistake about
something important?