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.

Combining interrupts with RTDX

Other Parts Discussed in Thread: CCSTUDIO

hello there !

 

I am trying to run the following code (red text )for BPSK modulator

I am fetching the variable "indata " value (for this case 10) from Matlab using RTDX, i need to know how could I pass this variable value to "interrupt void c_int11() ", I have read that, arguments could not be passed to interrupts, can any body help to find some alternate way of doing this?????

 

 

Regards,

 

Mirza Altamash Baig


//Modulation Scheme (BPSK)

#include "DSK6713_aic23.h"                //for BPSK Modulation
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;        //Sampling frequency

#include <math.h>

/**************************************************************************/
//BPSK Initialization:
/********************/

int i_BPSK_M;
int j_BPSK_M;

int masked_value, output ;


//Data table for BPSK MOD & DEMOD:
int data_BPSK[2][4]={0, 1000, 0, -1000,                                //0 degree       
                       0, -1000, 0, 1000};                            //180 degree       



interrupt void c_int11()                                             //interrupt service routine
{
   
int sample_data;   
                              // binary equivalent of 43690 (dec)=1010101010101010 (bin)
                            //52428=1100110011001100
                            //61680=1111000011110000
       
    
            //BPSK Modulator
            if (i_BPSK_M==64)                                        //determines when to get new input
              {
            sample_data = indata;            //input_sample()            //inputs data
                        
                i_BPSK_M=0;
                j_BPSK_M=0;
              }
     
              masked_value = sample_data & 0x0001;                            //masks input sample as 1-bit segments
              output = data_BPSK[masked_value][j_BPSK_M];     //gets corresponding level from table    
              output_sample(output*2);                                                      //outputs corresponding sinusoid
              j_BPSK_M++;                                                                  //repeated output counter
  
             if (j_BPSK_M==4)                                                                //checks if 1-bit segment was output                       
             {
                   j_BPSK_M=0;                       
                   sample_data = sample_data >> 1;                    //shifts input so as to mask another part
             }
              i_BPSK_M++;                                   
 
    return;
}



                               

void main(void)
{


int indata=10;

    i_BPSK_M=64;
    j_BPSK_M=0;
    comm_intr();                                                    //init DSK, codec, McBSP

 while(1);                                                     // infinite loop
}

  • PreviousIy I posted the code with omitted rtdx part, to emphasis only on the problem part, now I show the whole
    code "red text", one more thing is that For BPSK modulation vectors_intr.asm is used, while for rtdx intvecs.asm is used, but when I build the project,  compiler selects intvecs.asm as default interrupt and displays the following result in " Green text", the program has compiled with with no errors, but when I call the program from Matlab, the program runs until compiler get the value of indata variable and displays the result "Read Completed", but after that it doest not passes the indata value to interrupt, probably because during compilation compiler have selected only interrupt for rtdx and not for BPSK modulation, I am also attaching the projects in a single file (Files.rar) with this post

    1. BPSK modulation (bpsk_new_original)

    2. Matlab ,RTDX Simulation (rtdx_matlab_sim)

    3. Combined file having RTDX used with BPSK (rtdx_new)

    form the above projetcs 1 and 2 are working fine separately , but i need to merge the capabilities of 1 and 2 in 3 that is still undone , if some body have good suggestions please guide me,

     

    regards,

     

    Mirza Altamash Baig6087.Files.rar

     

    [c6713dskinit.c] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -g -q -fr"C:/CCStudio_v3.3/MyProjects/rtdx_test/Debug" -i"C:/CCStudio_v3.3/C6000/dsk6713/include" -i"C:/CCStudio_v3.1/c6000/rtdx/include" -d"CHIP_6713" -mv6710 --mem_model:data=far -@"../MyProjects/rtdx_test/Debug.lkf" "c6713dskinit.c"

    [Vectors_intr.asm] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -g -q -fr"C:/CCStudio_v3.3/MyProjects/rtdx_test/Debug" -i"C:/CCStudio_v3.3/C6000/dsk6713/include" -i"C:/CCStudio_v3.1/c6000/rtdx/include" -d"CHIP_6713" -mv6710 --mem_model:data=far -@"../MyProjects/rtdx_test/Debug.lkf" "Vectors_intr.asm"

    [intvecs.asm] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -g -q -fr"C:/CCStudio_v3.3/MyProjects/rtdx_test/Debug" -i"C:/CCStudio_v3.3/C6000/dsk6713/include" -i"C:/CCStudio_v3.1/c6000/rtdx/include" -d"CHIP_6713" -mv6710 --mem_model:data=far -@"Debug.lkf" "intvecs.asm"
    *** MESSAGE! line 20: INFO -- Compiling for JTAG RTDX by default.

    [RTDX_MATLAB_sim.c] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -g -q -fr"C:/CCStudio_v3.3/MyProjects/rtdx_test/Debug" -i"C:/CCStudio_v3.3/C6000/dsk6713/include" -i"C:/CCStudio_v3.1/c6000/rtdx/include" -d"CHIP_6713" -mv6710 --mem_model:data=far -@"Debug.lkf" "RTDX_MATLAB_sim.c"
    "RTDX_MATLAB_sim.c", line 100: warning: variable "indata" was declared but never referenced

    [Linking...] "C:\CCStudio_v3.3\C6000\cgtools\bin\cl6x" -@"Debug.lkf"
    <Linking>
    >> warning: creating output section .vecs without SECTIONS specification

    Build Complete,
      0 Errors, 2 Warnings, 0 Remarks.

     

     

     

     

    /**************************** RTDX Hearders *********************************/

    //MATLAB-DSK interface using RTDX between PC & DSK

    #include <rtdx.h>                                            //RTDX support file
    #include "target.h"                                //for init interrupt
    /****************************************************************************/
    RTDX_CreateInputChannel(ichan);   //create input channel-data transfer PC-->DSK
    RTDX_CreateOutputChannel(ochan);  //create output channel-data transfer DSK-->PC

    short indata;


    /********************************* BPSK Hearders ****************************/
    //Modulation Scheme (BPSK)

    #include "DSK6713_aic23.h"                //for BPSK Modulation
    Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;        //Sampling frequency

    #include <math.h>

    /**************************************************************************/
    //BPSK Initialization:
    /********************/

    int i_BPSK_M;
    int j_BPSK_M;

    int masked_value, output ;


    //Data table for BPSK MOD & DEMOD:
    int data_BPSK[2][4]={0, 1000, 0, -1000,                                //0 degree       
                           0, -1000, 0, 1000};                            //180 degree       



    interrupt void c_int11()                                             //interrupt service routine
    {
       
    int sample_data;   
                                  // binary equivalent of 43690 (dec)=1010101010101010 (bin)
                                //52428=1100110011001100
                                //61680=1111000011110000
           
        
                //BPSK Modulator
                if (i_BPSK_M==64)                                        //determines when to get new input
                  {
                sample_data = indata;            //input_sample()            //inputs data
                            
                    i_BPSK_M=0;
                    j_BPSK_M=0;
                  }
         
                  masked_value = sample_data & 0x0001;                //masks input sample as 1-bit segments
                  output = data_BPSK[masked_value][j_BPSK_M];            //gets corresponding level from table    
                  output_sample(output*2);                            //outputs corresponding sinusoid
                  j_BPSK_M++;                                            //repeated output counter
      
                 if (j_BPSK_M==4)                                    //checks if 1-bit segment was output                       
                 {
                       j_BPSK_M=0;                       
                       sample_data = sample_data >> 1;                    //shifts input so as to mask another part
                 }
                  i_BPSK_M++;                                   
     
        return;
    }



                                   

    void main(void)
    {


     TARGET_INITIALIZE();                              //init for interrupt
     RTDX_enableInput(&ichan);                     //for MATLAB to enable RTDX
      puts("\n\n Waiting to read ");                    //while waiting
     RTDX_read(&ichan,&indata,sizeof(indata));            //read data from PC to DSK
                                                       
    puts("\n\n Read Completed");                       
     

    //********************** BPSK Modulator ******************************************************/


        i_BPSK_M=64;
        j_BPSK_M=0;
        comm_intr();                                                    //init DSK, codec, McBSP

    //********************************************************************************************/

                                     

    /* RTDX_enableOutput( &ochan );                     //for MATLAB to enable RTDX
        puts("\n\n Waiting to write ");                  //while waiting

        RTDX_write(&ochan,&indata,sizeof(indata));            //send data from DSK to PC
        puts("\n\n Write Completed");
    */
     while(1);                                                     // infinite loop
    }1565.Files.rar

  • Mirza Altamash Baig,

    It's common practice to pass data or parameters into ISRs using global variables, but it's easy for things to go wrong.  Here are some guidelines that could help:

    1. When writing to the global variable in your non-ISR code, it's a good idea to temporarily disable interrupts, then write to the variable, then re-enable interrupts afterward.  In DSP/BIOS 5, the code looks like this:

      unsigned int context = HWI_disable();
      // set global variable here...
      HWI_restore(context);


      If your RTDX code is using interrupts to function, then this may not be applicable to your application.
    2. If something else (besides the DSP application code) has modified the global variable, you may need to take steps to preserve cache coherency.  This typically means invalidating the cache to make sure your ISR reads the latest data/parameters from the global variable.
    3. You can also declare the variable as volatile to make sure the compiler doesn't optimize out a read at the wrong time.