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.

Never reaching interrupts

Greetings!  I am lost; I think my program is too!

Here is the code snip:

<snip>

interrupt void c_int11() {

    // collect samples
    short sample_data;    // variable that stores the current sample
    short output;    // output variable for processed sample

    if (program_control == 0) {

        sample_data = input_left_sample();

        if (sample_data > threshold) signal_on = 1;

        if (signal_on) {

            if (column_index < column_len) {

                data_buffer.data[row_index][column_index].real = filter_signal(sample_data);
                column_index++;
            }

            if ( (row_index < row_len) && (column_index >= column_len) ) {

                row_index++;    // increment row index by 1
                column_index = 0;    // reset column index back to 0
                //printf("collecting frame number: %d\n", row_index);
            }
        }
    }

    if (row_index >= row_len) program_control = 1;    // move to next state
    // collect samples

    // playback
    if (program_control == 1) {

        output = playback();
        output_sample(output);

        if ( (output == 0) && (row < row_len) && (zero_count_flag == 0) ) {

            zero_count++;

            /*****************************************************************
             * row >= (row_len - 1) because playback() increments row_len will
             * at the end of its process.
             *****************************************************************/
            if (row >= (row_len - 1) ) {

                printf ("Counted %d zeros in collected samples.\n", zero_count);
                zero_count_flag = 1;
            }
        }
    }
    // playback

    return;
}

<snip>

Here is my problem.  I have a simple while loop in main():

while (program_control == 0);

My understanding is that while the statement is true, the CPU will check interrupts and run my code.  Is that wrong?  It must be because nothing is happening.

Here is my Vectors_intr.asm file:

<begin file>

*Vectors_intr.asm Vector file for interrupt INT11
   .global _vectors            ;global symbols
   .global _c_int00
   .global _vector1
   .global _vector2
   .global _vector3
   .global _vector4
   .global _vector5
   .global _vector6
   .global _vector7
   .global _vector8
   .global _vector9     
   .global _vector10
   .global _c_int11              ;for INT11
   .global _vector12 
   .global _vector13  
   .global _vector14
   .global _vector15

   .ref _c_int00                ;entry address

VEC_ENTRY .macro addr            ;macro for ISR
    STW   B0,*--B15
    MVKL  addr,B0
    MVKH  addr,B0
    B     B0
    LDW   *B15++,B0
    NOP   2
    NOP  
    NOP  
   .endm

_vec_dummy:
  B    B3
  NOP  5

 .sect ".vectors"                ;aligned IST section
 .align 1024
_vectors:
_vector0:   VEC_ENTRY _c_int00       ;RESET
_vector1:   VEC_ENTRY _vec_dummy      ;NMI
_vector2:   VEC_ENTRY _vec_dummy      ;RSVD
_vector3:   VEC_ENTRY _vec_dummy
_vector4:   VEC_ENTRY _vec_dummy
_vector5:   VEC_ENTRY _vec_dummy
_vector6:   VEC_ENTRY _vec_dummy
_vector7:   VEC_ENTRY _vec_dummy
_vector8:   VEC_ENTRY _vec_dummy
_vector9:   VEC_ENTRY _vec_dummy
_vector10:  VEC_ENTRY _vec_dummy
_vector11:  VEC_ENTRY _c_int11        ;ISR address
_vector12:  VEC_ENTRY _vec_dummy
_vector13:  VEC_ENTRY _vec_dummy
_vector14:  VEC_ENTRY _vec_dummy
_vector15:  VEC_ENTRY _vec_dummy

<end file>

Now, I don't claim to understand the assembly that's in this file.  But I have read up on some other posts and made the requested changes with no success.  I have also combed through some of the documentation and the Chassaing book and I still don't understand.

Could someone please help me understand how to properly execute an ISR with my code?

For background, here is what I think is going on:

+ I also have another variable that is declared as such `#define DEBUG <val>' .

 . When DEBUG was in c_int11(), I got my samples and everything ran nice.  As soon as I took DEBUG out of the ISR, nothing worked.

+ This tells me that even though program_control is initialized to 0 and stays at 0, the ISR is never fired. 

+ Obviously, I need to figure out how to check the appropriate registers, but I am not sure which ones to check and the IDE documentation is confusing to me.

 . I think I understand _why_ it's not working, I just don't understand _how_ to fix it.

Thank you for reading.

  • Natt,

    I'm a bit confused by your explanation. Can you clarify:

    You said you had a variable in c_int11() declared as '#define DEBUG <val>'

    #defines don't declare  variables, they just declare constants that are replaced by the preprocessor at compile time.  Did you mean that you declared a variable in c_int11() like the following?

    int foo = DEBUG;

    Where is program_control defined?  I see you using it to compare in the ISR.  Is it a global?  Since you are already using printfs. For debugging purposes, I would suggest putting a temporary printf at the top of the ISR so that you can see if the ISR is getting called and just not executing the code in the if() blocks, or if it is truely not getting called.

    Variables should not have an effect on whether ISRs are called or not However, they do have a big effect on what the ISR actually does.  

    Regards,
    Dan

     

     

     

     

     

     

  • Thanks for your reply, Dan.

    Dan: You said you had a variable in c_int11() declared as '#define DEBUG <val>'

    Me: I did say that debug is a variable.  Indeed, DEBUG is a constant.

    Dan: Where is program_control defined?

    Me: The variable program_control is a global variable.  And is defined as: volatile short program_control = 0;

    Dan: I would suggest putting a temporary printf at the top of the ISR so that you can see if the ISR is getting called and just not executing the code in the if() blocks, or if it is truely not getting called.

    Me: I put `printf("hello\n");' at the top of c_int11() and I did see `hello' in the console when debug runs.

    An interesting anecdote is that the variable `short sample_data;' is also declared in c_int11(), yet it shows up as undefined when I add it to the watch expression list.

    I hope these answers shed some light on my situation to give a better perspective.

  • Natt,

    There is a very large amount of information you need to understand to write bare-bones code like this, especially when you include assembly code. You can choose to go through several of the online C6000 training courses, some of which offer insights into some of the steps you are taking. Or you can use the coding model that TI fully supports, using DSP/BIOS or SYS/BIOS.

    DSP/BIOS or SYS/BIOS will be your best help. You need to start by writing your test application using DSP/BIOS (or SYS/BIOS if it is available for the C6713 and the version of CCS you are using). Many people who mention Chassaing are using the C6713 and CCS 3.3, plus you mentioned C6713 in your tags. But of course some of this is a guess since you did not explicitly tell us the DSP and tools you are using. That information may be useful when you reply next.

    Or if Chassaing gives you a complete code example, start from that.

    There are a lot of things that could be wrong with the code snippets that you have offered above, from assembly issues to C coding issues to variable types to compiler/optimizer switch settings. It is very difficult to debug someone else's code which was written from scratch. This is the reason we offer BIOS and examples for using BIOS. BIOS will handle the calling conventions required for interrupts and the context save & restore (remember to remove the interrupt keyword). The best first place would be to move to CCSv5.1 and SYS/BIOS, then go to the TI Wiki Pages and search for "SYS/BIOS Workshop" (no quotes); the 1.5 Day Workshop is a great intro and it includes some ideas on examples. There will be no licensing fees for using CCSv5.1 with your DSK and the onboard emulator. You may want to look at my favorite Wiki page, GSG:Common target configurations.

    This may not be the best answer you can get on the forum, but in my opinion it is the best direction you can go to succeed on your project.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Thanks, RandyP.  I will heed your advice.  There is obviously much I don't understand.  In the mean time, I have uploaded my project to github.  Please take a look if you are so inclined and maybe something will pop out at you...  You will see from the code that I have cherry picked a few functions from some other programs.

    https://github.com/staticd/TheGatorKator/

    As for other details:

    Hardware platform: TMS320DSK6713

    Development Environment: CCS v 5.1