This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

StarterWare 1.20.04.01 McASP Example without EDMA

Hi, i'm trying McASP on c6748 LCDK with XDS100v2.

 

The loopback example of McASP from StarterWare can work.

In the example, the EDMA with ping-pong operation transfers/receives the buffers.

But I want to apply adaptive echo cancellation, data by data, for the real-time processing.

I'm trying two ways now

 

 

1. Reduce the sizes of buffers

I've tried to make NUM_SAMPLES_PER_AUDIO_BUF as 2 (one data for two channel)

And play the 1kHz sine wave which is produced by the code below:

short y1[3] = {0, -11585 , -16384};
const short A1 = 23170;

y1[0] = (short)(((int)y1[1]*A1 + ROUND )>> 14) - y1[2];
y1[2] = y1[1];
y1[1] = y1[0];

But I don't know why the txbuffer is always 0.

 

2. Delete the API of EDMA and configure the McASP without EDMA

 

 

Did anyone have this kinds of experences?

It has bothered me two weeks. Please help me.

  • Hi Titus,

    I used the example from C6748_StarterWare_1_20_04_01\build\c674x\cgt_ccs\c6748\lcdkC6748\mcasp.

    Delete the EDMA part and set the McASP according to the McASP guide.

    I thought I have checked all of the registers of McASP.

    But the audio can not playback. Could you help me to fixed it?

    I'm using DSP because of work after graduated on February.

    Without any experience of DSP, my progress is very slow.

    I'm very appreciated for any suggestions or directions.

    Thank you very much.

    #include "interrupt.h"
    #include "soc_C6748.h"
    #include "hw_syscfg0_C6748.h"
    #include "lcdkC6748.h"
    #include "codecif.h"
    #include "mcasp.h"
    #include "aic31.h"
    #include "psc.h"
    
    #include <string.h>
    
    /******************************************************************************
    **                      INTERNAL MACRO DEFINITIONS
    ******************************************************************************/
    /*
    ** Values which are configurable
    */
    /* Slot size to send/receive data */
    #define SLOT_SIZE                             (16u)
    
    /* Word size to send/receive data. Word size <= Slot size */
    #define WORD_SIZE                             (16u)
    
    /* Sampling Rate which will be used by both transmit and receive sections */
    #define SAMPLING_RATE                         (8000u)
    
    /* Number of channels, L & R */
    #define NUM_I2S_CHANNELS                      (2u) 
    
    /* AIC3106 codec address */
    #define I2C_SLAVE_CODEC_AIC31                 (0x18u) 
    
    /* Interrupt channels to map in AINTC */
    #define INT_CHANNEL_I2C                       (2u)
    #define INT_CHANNEL_MCASP                     (2u)
    
    /* McASP Serializer for Receive */
    #define MCASP_XSER_RX                         (14u)
    
    /* McASP Serializer for Transmit */
    #define MCASP_XSER_TX                         (13u)
    
    /*
    ** Below Macros are calculated based on the above inputs
    */
    
    #define I2S_SLOTS                             ((1 << NUM_I2S_CHANNELS) - 1)
    
    
    /*
    ** Definitions which are not configurable 
    */
    
    
    /******************************************************************************
    **                      INTERNAL FUNCTION PROTOTYPES
    ******************************************************************************/
    static void McASPRxIsr(void);
    static void McASPIntSetup(void);
    static void AIC31I2SConfigure(void);
    static void McASPI2SConfigure(void);
    static void I2SDataTxRxActivate(void);
    
    /******************************************************************************
    **                      INTERNAL VARIABLE DEFINITIONS
    ******************************************************************************/
    static unsigned int buffer;
    /****************************************************************************** ** FUNCTION DEFINITIONS ******************************************************************************/ /* ** Function to configure the codec for I2S mode */ static void AIC31I2SConfigure(void) { volatile unsigned int delay = 0xFFF; AIC31Reset(SOC_I2C_0_REGS); while(delay--); /* Configure the data format and sampling rate */ AIC31DataConfig(SOC_I2C_0_REGS, AIC31_DATATYPE_I2S, SLOT_SIZE, 0); AIC31SampleRateConfig(SOC_I2C_0_REGS, AIC31_MODE_BOTH, SAMPLING_RATE); /* Initialize both ADC and DAC */ AIC31ADCInit(SOC_I2C_0_REGS); AIC31DACInit(SOC_I2C_0_REGS); } /* ** Configures the McASP Transmit Section in I2S mode. */ static void McASPI2SConfigure(void) { McASPRxReset(SOC_MCASP_0_CTRL_REGS); McASPTxReset(SOC_MCASP_0_CTRL_REGS); /* Set I2S format in the transmitter/receiver format units */ McASPRxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE, MCASP_RX_MODE_NON_DMA); McASPTxFmtI2SSet(SOC_MCASP_0_CTRL_REGS, WORD_SIZE, SLOT_SIZE, MCASP_TX_MODE_NON_DMA); /* Configure the frame sync. I2S shall work in TDM format with 2 slots */ McASPRxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_RX_FS_WIDTH_WORD, MCASP_RX_FS_EXT_BEGIN_ON_FALL_EDGE); McASPTxFrameSyncCfg(SOC_MCASP_0_CTRL_REGS, 2, MCASP_TX_FS_WIDTH_WORD, MCASP_TX_FS_EXT_BEGIN_ON_RIS_EDGE); /* configure the clock for receiver */ McASPRxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL, 0, 0); McASPRxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_POL_RIS_EDGE); McASPRxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLKCHCK_DIV32, 0x00, 0xFF); /* configure the clock for transmitter */ McASPTxClkCfg(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_EXTERNAL, 0, 0); McASPTxClkPolaritySet(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_POL_FALL_EDGE); McASPTxClkCheckConfig(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLKCHCK_DIV32, 0x00, 0xFF); /* Enable synchronization of RX and TX sections */ McASPTxRxClkSyncEnable(SOC_MCASP_0_CTRL_REGS); /* Enable the transmitter/receiver slots. I2S uses 2 slots */ McASPRxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); McASPTxTimeSlotSet(SOC_MCASP_0_CTRL_REGS, I2S_SLOTS); /* ** Set the serializers, Currently only one serializer is set as ** transmitter and one serializer as receiver. */ McASPSerializerRxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX); McASPSerializerTxSet(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX); /* ** Configure the McASP pins ** Input - Frame Sync, Clock and Serializer Rx ** Output - Serializer Tx is connected to the input of the codec */ McASPPinMcASPSet(SOC_MCASP_0_CTRL_REGS, 0xFFFFFFFF); McASPPinDirOutputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AXR(MCASP_XSER_TX)); McASPPinDirInputSet(SOC_MCASP_0_CTRL_REGS, MCASP_PIN_AFSX | MCASP_PIN_ACLKX | MCASP_PIN_AFSR | MCASP_PIN_ACLKR | MCASP_PIN_AXR(MCASP_XSER_RX)); /* Enable error interrupts for McASP */ // McASPTxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_TX_DMAERROR // | MCASP_TX_CLKFAIL // | MCASP_TX_SYNCERROR // | MCASP_TX_UNDERRUN); McASPRxIntEnable(SOC_MCASP_0_CTRL_REGS, MCASP_RX_DATAREADY); } /* ** Sets up the error interrupts for McASP in AINTC */ static void McASPIntSetup(void) { #ifdef _TMS320C6X IntRegister(C674X_MASK_INT5, McASPRxIsr); IntEventMap(C674X_MASK_INT5, SYS_INT_MCASP0_INT); IntEnable(C674X_MASK_INT5); #else /* Register the error ISR for McASP */ IntRegister(SYS_INT_MCASPINT, McASPRxIsr); IntChannelSet(SYS_INT_MCASPINT, INT_CHANNEL_MCASP); IntSystemEnable(SYS_INT_MCASPINT); #endif } /* ** Activates the data transmission/reception ** The DMA parameters shall be ready before calling this function. */ static void I2SDataTxRxActivate(void) { /* Start the clocks */ McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL); McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_EXTERNAL); /* Activate the serializers */ McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS); McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS); // /* make sure that the XDATA bit is cleared to zero */ // while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY); /* Activate the state machines */ McASPRxEnable(SOC_MCASP_0_CTRL_REGS); McASPTxEnable(SOC_MCASP_0_CTRL_REGS); } /* ** The main function. Application starts here. */ int main(void) { /* Set up pin mux for I2C module 0 */ I2CPinMuxSetup(0); McASPPinMuxSetup(); /* Power up the McASP module */ PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_MCASP0, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE); #ifdef _TMS320C6X // Initialize the DSP interrupt controller IntDSPINTCInit(); #else /* Initialize the ARM Interrupt Controller.*/ IntAINTCInit(); #endif /* Initialize the I2C 0 interface for the codec AIC31 */ I2CCodecIfInit(SOC_I2C_0_REGS, INT_CHANNEL_I2C, I2C_SLAVE_CODEC_AIC31); McASPIntSetup(); #ifdef _TMS320C6X IntGlobalEnable(); #else /* Enable the interrupts generation at global level */ IntMasterIRQEnable(); IntGlobalEnable(); IntIRQEnable(); #endif /* Configure the Codec for I2S mode */ AIC31I2SConfigure(); /* Configure the McASP for I2S */ McASPI2SConfigure(); /* Activate the audio transmission and reception */ I2SDataTxRxActivate(); for(;;); } /* ** Rx ISR for McASP */ static void McASPRxIsr(void) { buffer = McASPRxBufRead(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_RX); McASPTxBufWrite(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX, buffer); }

    Best Regards,

    Alan

  • The problem has been solved.
  • Could you please post what was the problem here?
  • Hi Ka,

    The problem I'm facing here is why my code ,McASP without EDMA, cannot work.
    The code was modified by the sample of StarterWare.
    After checking some details of TRM, the step of activating McASP goes wrong.

  • Hi Alan,
    I am asking about that because I have a similar problem. I cannot get any signal on the output.
    Could you please post what exactly was wrong in this code or just post your correct script here?

    Thanks,
    Ka

  • Hi Ka,

    The solution here is that I gave an initial value for TxBuf before McASPRxSerActivate & McASPTxSerActivate.

    I hope it can solve your problem too. 

    Best Regards,

    Alan

  • Hi Alan,
    It does not work for me, but thanks for your answer.

    Best regards,
    Ka
  • Hi Alan,

    When you decide to initialize Txbuff, you mean to put buffer = 0? .

    Could you please post the code you have working?.

    Thanks in advance.

    Best Regards.

    Santi

  • Hi Santi,

    Yes, the method of initialize is showed below.

    static void I2SDataTxRxActivate(void)
    {
        /* Start the clocks */
        McASPRxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_RX_CLK_EXTERNAL);
        McASPTxClkStart(SOC_MCASP_0_CTRL_REGS, MCASP_TX_CLK_EXTERNAL);
    
        /* Activate the serializers */
        McASPRxSerActivate(SOC_MCASP_0_CTRL_REGS);
        McASPTxSerActivate(SOC_MCASP_0_CTRL_REGS);
    
        McASPTxBufWrite(SOC_MCASP_0_CTRL_REGS, MCASP_XSER_TX, 0x0);    // Initialize the tx buffer here
    
        /* make sure that the XDATA bit is cleared to zero */
        while(McASPTxStatusGet(SOC_MCASP_0_CTRL_REGS) & MCASP_TX_STAT_DATAREADY);
    
        /* Activate the state machines */
        McASPRxEnable(SOC_MCASP_0_CTRL_REGS);
        McASPTxEnable(SOC_MCASP_0_CTRL_REGS);
    }

    Actually this code is the example from StarterWare.

    So the only different is that I added McASPTxBufWrite before activated.

    I hope this will help.

    Best Regards,

    Alan