AnsweredAssumed Answered

DebugMon interrupt

Question asked by biafra on Nov 26, 2018
Latest reply on Nov 30, 2018 by LPCX presso support

Hi everyone

 

I'm using MCUXpresso 10.2.1 and a custom board based on MK66F2N0.

 

To catch a bug about writing on a variable, I'd want to use the debug monitor interrupt. I've configured the DWT peripheral to set the debug monitor interrupt, but I have two problems:

  • Every time I write the variable, the program stops if there is the debug probe connected (P&E multilink universal), whether if it's running a debug session or a release session
  • The interrupt is never executed (both with the debug probe connected or not)

 

This the code I use:

 

unsigned long DebugVar = 0;
unsigned long DebugHandler = 0;

 

void main( void )
{
   unsigned long DebugCnt = 0;

 

   ...

 

   //init debugmon
   CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk | CoreDebug_DEMCR_MON_EN_Msk;
   DWT->COMP0 = ( uint32_t )&DebugVar;
   DWT->MASK0 = 0;
   DWT->FUNCTION0 = ( 1 << 11 ) | ( 1 << 2 ) | ( 1 << 0 );

   NVIC_SetPriority( DebugMonitor_IRQn, 7 );
   EnableIRQ( DebugMonitor_IRQn );

 

   while( 1 )
   {
      if( DebugCnt++ >= 100 ) //every 10 s
      {
         DebugCnt = 0;
         DebugVar++; //write var
      }

 

      ...

 

      if( DebugHandler )
      {
         //debug
         PRINTF( "Debug monitor handler executed\n" );
         DebugHandler = 0;
      }

      vTaskDelay( 10 ); //systick = 10 ms: delay 100 ms

   }
}

 

void DebugMon_Handler( void )
{
   if( DWT->FUNCTION0 & DWT_FUNCTION_MATCHED_Msk )
      DebugHandler = 1;
}

 

Is there any error? Why is the interrupt never executed? Is it possible to avoid stopping the execution during the debug session?

 

Many thanks

Biafra

Outcomes