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.

generating sine wave from PADK C6727

Hello, I am actually working on the PADK C6727 for an ANC project and im very new to the programming of the PADK. I cannot understand the function of : interrupt void nmi_isr() Furthermore, I will need to generate a sinusoidal wave from the PADK for the identification of secondary path in ANC. Can you tell me how to proceed please? Thanks,
  • Sajaad Boodoo,

    Welcome to the TI E2E forum. I hope you will find many good answers here.
    In addition you can find some details through the TI.com documents and the TI Wiki Pages.
    Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics.

    INTC Module:
    The interrupt module provides interrupt management services and a dispatcher.
    This module is delivered as a separate library.

    The INTC module in CSL3.x is designed to provide an abstraction for all the basic interrupt controller functions, such as enabling and disabling interrupts, specifying the user function to be called in response to interrupts, and setting desired hardware properties.

    The EMIF EM_WAIT pin has the ability to generate an NMI (INT1) based upon a rising edge on the EM_WAIT pin. Note that while this interrupt is connected to the CPU NMI (non-maskable interrupt), it is actually maskable through the EMIF control registers. In fact, the default state for this interrupt is disabled.

    Please have a look at this wiki article, it will help you for PADK,
    http://processors.wiki.ti.com/index.php/Converting_from_INTC_to_BIOS#Process_for_C6727_Project

    The C672x CSL provides an API for configuring and controlling the on-chip peripherals for easy compatibility between various C672x devices. 
    http://www.ti.com/tool/sprc223 

  • Hi..

    I have written a program on CCS 4.2 for the generation of a sine wave from PADK C6727. it seems the program is running and also being loaded successfully on the PADK, but I don't hear any output via a headphone. in fact, I have modified the existing program for analog loopback by including the sine wave generation in the interrupt service routine.

    The sampling rate used for the sine wave has been set at 48 kHz. Is there anything we need to modify in the PADK for something which is generated internally?

    Thanks,

    Sajaad

  • In my opinion you have to create periodic interrupt from RTI. In your case sampling frequency is 48kHz, so it's Ts = 1/fs = 20,83us. In interrupt routine of RTI you have to clear interrupt flag of RTI and you can calculate sample of the sinusoidal wave. Sine wave is generally getting by:

    u(t) = um*sin(2*pi*f*t + phase)

    t = t + Ts. If Ts=period of your sine wave t=0. Then you have to calculate value for your DAC and send your sample to the DAC. Off course you can use dMax and sine table to do that. In this case interrupt routine should be make once per period.

    I hope it's helpful and you can understand me.

  • Hi,

    Thanks a lot for your help.

    In fact, I have used the dMax and sine and modified the analog loopback program. Below is the section that I have modified while the other remaining part of the program, stays the same.

     

    interrupt void nmi_isr( void )

    {

        while(1);

    }

    interrupt void dmax_isr( void )

    {

           unsigned PP;

        volatile unsigned *GPTransferEntry;

        static int *pDac = (int *)dmaxDacBuffer[0];

        //static int *pAdc = (int *)dmaxAdcBuffer[0];//

       

        //sinewave generation//

           #define SAMPLING_FREQ 48000

        #define PI 3.142

        float frequency = 1000.0;

        float amplitude = 10000.0;

        float theta_increment;

        float theta = 0.0;

        static int *psinout;

       

        float sinewave();

        {

           theta_increment = 2*PI* frequency/SAMPLING_FREQ ;

           theta += theta_increment;

           if (theta>2*PI) theta -=2*PI;

           *psinout = amplitude*sin(theta);

           return;

        }

             /*

           // Verify if a ADC transfer completed

           if( hDmaxAdc->regs->DTCR0 & (1<<ADC_TCC) )

           {

                  hDmaxAdc->regs->DTCR0 = (1<<ADC_TCC);

     

                  // Save the pointer of the audio buffer that has just been filled

                  GPTransferEntry  = (unsigned *)&hDmaxAdc->regs->HiPriorityEventTable;

                  GPTransferEntry += ((*(hDmaxAdc->hiTableEventEntryPtr)>>8)&0x07F);

               PP = GPTransferEntry[2] >> 31;      

                  pAdc = (int *)dmaxAdcBuffer[!PP];

                 }     

                   */

          

                  // Verify if a DAC transfer completed

                         if( hDmaxDac->regs->DTCR0 & (1<<DAC_TCC) )

                           {

                               hDmaxDac->regs->DTCR0 = (1<<DAC_TCC);

     // Save the pointer of the audio buffer that has just been transmitted

     GPTransferEntry  = (unsigned *)&hDmaxDac->regs->HiPriorityEventTable;

           GPTransferEntry += ((*(hDmaxDac->hiTableEventEntryPtr)>>8)&0x07F);

                             PP = GPTransferEntry[2] >> 31;      

                         pDac = (int *)dmaxDacBuffer[!PP];

                                     

                   // Copy new samples in transmit buffer

                  memcpy( pDac, psinout, FRAME_SIZE*NUM_CHANNEL*2*sizeof(int) );

                   }

     }                   

    when the program is build, it does not give any error but only one warning as follows:

    "statement is unreachable" at line  " if( hDmaxDac->regs->DTCR0 & (1<<DAC_TCC) )".

    when the program is loaded on the PADK, it appears fine but there is no output on a headphone.

     

    Thanks,