Re: McASP Initialisation on C6713



Hi,

i solved the problem with some wait loops.

//*----------------------------------------------------------------------------*/
//* McASP initialization function
//*
//* port: McASP port
//*----------------------------------------------------------------------------*/
void mcasp_init( )
{
/* global registers */ MCASP_ConfigGbl cfgMCASPGBL = {
/* pin function register */
........... };

hMcasp = MCASP_open( MCASP_DEV1, MCASP_OPEN_RESET );

if ( hMcasp != INV )
{ MCASP_configGbl( hMcasp, &cfgMCASPGBL );
MCASP_configRcv( hMcasp, &cfgMCASPRCV );
MCASP_configXmt( hMcasp, &cfgMCASPXMT );
MCASP_configSrctl( hMcasp, &cfgMCASPSRCTL );
/* enable clocks */
MCASP_enableHclk( hMcasp, MCASP_RCVXMT ); while(!(
MCASP_FGETH( hMcasp, GBLCTL, XHCLKRST ) && MCASP_FGETH( hMcasp, GBLCTL,
RHCLKRST )));
MCASP_enableClk( hMcasp, MCASP_XMTRCV );
while(!( MCASP_FGETH( hMcasp, GBLCTL, XCLKRST ) && MCASP_FGETH(
hMcasp, GBLCTL, RCLKRST )));
edma_init( );
/* enable serializer */
MCASP_enableSers( hMcasp, MCASP_RCVXMT );
while(!(MCASP_FGETH( hMcasp,GBLCTL,RSRCLR ) && MCASP_FGETH(
hMcasp,GBLCTL,XSRCLR )));

/* enable state machine */ MCASP_enableSm(
hMcasp, MCASP_RCVXMT );
while(!(MCASP_FGETH( hMcasp,GBLCTL,RSMRST ) && MCASP_FGETH(
hMcasp,GBLCTL,XSMRST )));
/* enable frame sync */
MCASP_enableFsync( hMcasp, MCASP_RCVXMT );
while(!(MCASP_FGETH( hMcasp,GBLCTL,RFRST ) && MCASP_FGETH(
hMcasp,GBLCTL,XFRST )));

/* wait for clock synchronise (no clock failure detected) */
while ( MCASP_FGETH( hMcasp, RSTAT, RCKFAIL ) )
{ MCASP_RSETH( hMcasp, RSTAT, 0x0000ffff);
/* wait one HCLK period (128) */
for ( i = 0; i < 150; i++ )
asm(" nop"); }
while ( MCASP_FGETH( hMcasp, XSTAT, XCKFAIL ) )
{
MCASP_RSETH( hMcasp, XSTAT, 0x0000ffff);
for ( i = 0; i < 150; i++ )
asm(" nop");
}
}
}

And with the following functions i checked the states in debug-mode after
the mcasp initialisation and in the main loop.

//*----------------------------------------------------------------------------*/
//* State Machine Check Function
//*
//* check the XSTAT and RSTAT register
//*
//* this function is only for debug
//*
//* check: register to check
//*----------------------------------------------------------------------------*/
void sm_error( int check )
{
/* int error = 0;

if ( check & 0x1 )
error = 1; // underrun
if ( check & 0x2 )
error = 1; // sync error
if ( check & 0x4 )
error = 1; // clock fail
if ( check & 0x8 )
error = 1; // tdm slot is even
if ( check & 0x10 )
error = 1; // slot is the last in frame
if ( check & 0x20 )
error = 1; // data is cp from buf to rsr
if ( check & 0x40 )
error = 1; // new frame detected
if ( check & 0x80 )
error = 1; // dma error
if ( check & 0x100 )
error = 1; // error*/
}

//*----------------------------------------------------------------------------*/
//* TDM Sequencer Check Function
//*
//* check the XSLOT and RSLOT register
//* current receive/transmit time slot
//*
//* this function is only for debug
//*
//*----------------------------------------------------------------------------*/
void tdm_check( )
{
/* int error = 0;

rcvcount = MCASP_getRslotcnt( hMcasp );
xmtcount = MCASP_getXslotcnt( hMcasp );
if ( rcvcount != 0x1 )
if ( rcvcount != 0x2 )
error = 1; // Receive time slot 2 is inactive
else
error = 2; // Receive time slot 1 is inactive

if ( xmtcount != 0x1 )
if ( xmtcount != 0x2 )
error = 1; // Transmit time slot 2 is inactive
else
error = 2; // Transmit time slot 1 is
inactive*/
}

//*----------------------------------------------------------------------------*/
//* MCASP Check Function
//*
//* check if clock, hclock, serializer, sm and frame sync is running
//*
//* this function is only for debug
//*
//*----------------------------------------------------------------------------*/
void gblctl_check()
{
/* int error = 0;

gblctl = MCASP_getGblctl( hMcasp, MCASP_RCVXMT );
rcvgblctl = MCASP_getGblctl( hMcasp, MCASP_RCV );
xmtgblctl = MCASP_getGblctl( hMcasp, MCASP_XMT );

if( !(gblctl & 0x1) )
error = 1; // clock divider is in reset
if( !(gblctl & 0x2) )
error = 1; // hclock divider..
if( !(gblctl & 0x4) )
error = 1; // serializer..
if( !(gblctl & 0x8) )
error = 1; // state machine..
if( !(gblctl & 0x10) )
error = 1; // frame sync..*/
}

I hope it helps. Good luck.



_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?
.