3

I'm using LCDK C6748 of Texas Intruments with Code Composer Studio and TMDSEMU100V2U-14T - XDS100v2 USB JTAG Emulator.

LCDK comes with bunch of support functions, including a function that initialize the board and defines which callback functions are called for each interrupt.

I just implemented the callback function, so it does something whenever a new sample comes from the ADC.

I tried to set a breakpoint inside the interrupt but in run time the program "flow" didn't get there.

Furthermore, I've done something simpler:

volatile int flag = 0;


interrupt void interrupt4(void) // interrupt service routine
{
   flag = 1;
   return;
}

int main(){
    // board initializing function, defining sampling rate etc.
    L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB);

    while(1){
       if (flag == 1){
          printf("interrupt entered");
          flag = 0;
       }
    }
}

but the from some reason the while loop was entered only once.

it surprised me because if I don't set breakpoint the interrupt is entered continuously- I tried to just pass the samples to the speakers line without doing anything else and I heard music.

I have a feeling that I'm missing something very basic about interrupts, I'm quite new to this subject.

Can someone please explain to me [or link me to good source that explain how the mechnism works in DSP]:

1) why we can't set a breakpoint inside interrupt?

2) why even if I set breakpoint in the main, it seems the interrupt doesn't occur, and if I don't it does.

3) which ways I have to have access to the variables in run time, in CCS?

thanks

Day_Dreamer
  • 3,311
  • 7
  • 34
  • 61
  • The obvious thing, to me anyway, is that you should be entering the while loop given that `flag == 1` is true, for the duration of the program. My question then is are you sure the scope of the `volatile int flag` is indeed global? Have you verified that execution flow _always_ returns from `L138_initialise_intr`? – ryyker Jan 12 '15 at 20:38
  • both the callback implementation and the main are in the same .c file and the flag is declared: volatile int flag=0; in the head of it – Day_Dreamer Jan 12 '15 at 20:40
  • Can you post the relevant parts of your callback? (all of it if it is not too big) There may be a return on error condition before you set `flag = 0;`. That would be a reason why you never enter the `while(...)` in `main()`. – ryyker Jan 12 '15 at 20:42
  • I see that. Hmm, The only other question for me is how are you verifying new ADC events are occurring?, and are you sure you have mapped events to the right callback? i.e., is there a possibility that `interrupt4` is not mapped to ADC events? – ryyker Jan 12 '15 at 20:52
  • I'm quite sure that the callback is mapped ok (this is done by the support initializing function) and as I mentioned while I do not set breakpoint and just push every new sample to the speakers line within the callback, I hear music, so it works... – Day_Dreamer Jan 12 '15 at 20:56
  • Given you have a complete, and closed loop execution flow, (i.e., you hear noise) and the condition for entering the while() loop is hard-coded to true, the only other possibility I can think of is perhaps some deficiency, or undefined way in which your debugger handles breakpoints. – ryyker Jan 12 '15 at 21:13
  • 2
    Breakpoint in ISR - see previous question http://stackoverflow.com/questions/325718/can-breakpoints-be-used-in-in-isrs – Weather Vane Jan 12 '15 at 21:17
  • 2
    Did you clear the source of the interrupt? Not in your example. Depending on whether the interrupt is level- or edge- triggered, this will make a difference to whether it is called continually or once. – Weather Vane Jan 12 '15 at 21:20
  • hey, you mean set the mask in a way to enable the next interrupt? in my example I've done just what you can see. I didn't take care about cleaning. without BP it actually worked ok - so I assumed the initializing function is doing this for me. – Day_Dreamer Jan 13 '15 at 14:52
  • What is the interrupt4? I mean which is the specific interrupt that call your ISR? – LPs Jan 13 '15 at 16:24

2 Answers2

2

I think that your interrupt is a Timer Interrupt. In many cases jtag, when a breakpoint is triggered, stops a lot of MPU/DSP modules, but timer continue running. This causes overflow of timer, that means that overflow flag is set and the interrupt will be never called until the flag is reset.

I don't know if you can set jtag to stop timers also when a breakpoint is triggered. With freescale MPUs, IAR IDE and segger jtag I can.

LPs
  • 16,045
  • 8
  • 30
  • 61
2
  1. Try putting breakpoint and then run. see if it hits atleast once. If it does, then your interrupt source is not cleared automatically [because you are not doing so explicitly inside ISR]. in TI controller they expect you to clear ISR path to receive next as per my experience,.
  2. If you dont receive even 1st time interrupt then, check assembly generated for ISR and optimization done by compiler.

  3. Although, you might need to see the timing and global variable protection later, in case of conflicts but as of now above 2 suggestions shall do.

Varun Mishra
  • 111
  • 1
  • 7