I have been trying to generate a 1 KHz tone, using the EVMOMAP-L137. I started from the spectrum digital AIC Test and slowly tried to combine this with EDMA. Sadly I'm running into issue where my signal sounds and looks noisy,
I'm not doing ping pong but I'm also not doing any processing. If I service the McASP buffers directly in a for loop I get the red line but if I try to configure the EDMA the results looks like the orange line.
I have verified everything that I can, gone through forums and read through the documentation but I can't figure out how to do this with EDMA.
Any suggestions will be greatly appreciated.
Here is my code:
unsigned short dataout[48] = {
0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,
0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x763f,
0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,
0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,
0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,
0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c
};
unsigned int datain[48];
void *mcasp_xmt_register = (void *)(MCASP1_BASE + 0x214);
void *mcasp_rcv_register = (void *)(MCASP1_BASE + 0x280);
/*
* ======== main ========
*/
void main()
{
/* Initialize i2c */
I2C_Init();
// Configure DS1 (User LEDs) as output
GPIO_Set_Direction(12, GPIO_OUT);
// Turn off LEDs (Desired initial state)
GPIO_Set_Output(12, GPIO_ON);
BIOS_start();
}
/*
* ======== Task Function 0 ========
*/
void task0function()
{
short msec;
short sec;
short sample;
for ( sample = 0 ; sample < 48 ; sample++ )
{
datain[sample]=0;
// dataout[sample]=dataout[sample]<<16;
}
/*Initialize edma*/
Edma3_Init();
Edma3_Setup_McASP_XMT(dataout, mcasp_xmt_register, 2, 48);
// Edma3_Ping_XMT(dataout, dataout, mcasp_xmt_register, 2, 48);
Edma3_Enable_Channel(EDMA_MCASPTXCH, 0);
Edma3_Enable_Interrupt(EDMA_MCASPTXCH_TCC);
//Intrinsic Function to Enable Interrupts
_enable_interrupts();
/* Initialize AIC3106 */
AIC3106_Initialize();
/* Initialize McASP1 */
MCASP_Open(MCASP_1);
/* Record Tone */
for ( sec = 0 ; sec <2 ; sec++ )
{
for ( msec = 0 ; msec < 1000 ; msec++ )
{
for ( sample = 0 ; sample < 48 ; sample++ )
{
/* Send a sample to the left channel */
// while ( ! ( MCASP1_SRCTL5 & 0x10 ) );
// MCASP1_XBUF5_32BIT = (dataout[sample] << 0);
/* Read the right sample */
while ( ! ( MCASP1_SRCTL0 & 0x20 ) );
datain[sample] = MCASP1_RBUF0_32BIT >> 0;
/* Send a sample to the right channel */
// while ( ! ( MCASP1_SRCTL5 & 0x10 ) );
// MCASP1_XBUF5_32BIT = (dataout[sample] << 0);
/* Read the left sample */
while ( ! ( MCASP1_SRCTL0 & 0x20 ) );
datain[sample] = MCASP1_RBUF0_32BIT >> 0;
}
}
}
//Intrinsic Function to Disable Interrupts
_disable_interrupts();
/* Close Codec */
AIC3106_Close();
/* Close McASP */
MCASP_Close(MCASP_1);
/* Close I2C */
I2C_Close( );
for ( sample = 0 ; sample < 48 ; sample++ )
{
datain[sample]=datain[sample] >> 16;
System_printf("%d\n",(short)datain[sample]);
}
BIOS_exit(0);
}
/*
* ======== clk0Fxn =======
*/
void clk0function(UArg arg0)
{
GPIO_Toggle(12);
}
/*
* ======== edma3isr ========
*/
int edma3ccisr()
{
while(edma3ccRegs->IPR != 0)
{
if (edma3ccRegs->IPR & (1 << EDMA_MCASPTXCH_TCC))
{
Edma3_Clear_Interrupt(EDMA_MCASPTXCH_TCC);
// Semaphore_post(xmtsemhandle);
}
if (edma3ccRegs->IPR & (1 << EDMA_MCASPRXCH_TCC))
{
Edma3_Clear_Interrupt(EDMA_MCASPRXCH_TCC);
// Semaphore_post(rcvsemhandle);
}
}
return 0;
}
and here is my EDMA setup:
int Edma3_Setup_McASP_XMT(void *src, void *dst, unsigned int sample_size, unsigned int sample_count)
{
CSL_Edma3ccParamSetRegs param;
param.SRC = (unsigned int)src;
param.DST = (unsigned int)dst;
param.A_B_CNT = (2 << 16) | (sample_size); // actual format: BCNT|ACNT ACnt is 2 bytes or 16 bit word
param.CCNT = sample_count; // our array has 48 samples for single 48 KHz period
param.SRC_DST_BIDX = (0 << 16) | 0; // actual format: DSTBIDX|SCRBIDX
param.SRC_DST_CIDX = (0 << 16) | sample_size; // actual format: DSTCIDX|SRCCIDX
param.OPT = (1 << 20) | (EDMA_MCASPTXCH_TCC << 12); // transfer complete interrupt enabled, A Synch Mode
param.LINK_BCNTRLD = (2 << 16) | (EDMA_MCASPTXCH_RLD << 5); // actual format: BCNTRLD|LINK
Edma3_Write_PaRAM(EDMA_MCASPTXCH, ¶m);
Edma3_Write_PaRAM(EDMA_MCASPTXCH_RLD, ¶m);
return 0;
}