MQX UNHANDLED INTERRUPT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MQX UNHANDLED INTERRUPT

6,285 Views
OldNick
Contributor IV

Getting this error (0x00041) on a Kinetis (MQX370)  under IAR

 

If I step the program, the error occurs in different places. 

 

Sometimes it even thinks it has occurred in threads that are waiting for events.

 

I have multiple tasks running at a variety of priorities (including PEG), and suspect the C++ STL code in the application.  But can't prove it.

 

Does anybody know how to debug it?

 

12 Replies

1,599 Views
DavidS
NXP Employee
NXP Employee

Hi OldNick,

Did you install the following:

_int_install_unexpected_isr();

Note some Kinetis peripheral modules continue on clocking even when debugger is halted or singlestepping.  This can cause weird and inconsistent results.  The PDB with the ADC is one example.

Regards,

David

0 Kudos

1,599 Views
DavidS
NXP Employee
NXP Employee

Hi OldNick,

Sticky problem but I'd still try installing the unexpected isr....cannot hurt to try.

You can also add in kernel logging and when error occurs look at it:

#if

MQX_USE_LOGS

 

/* create the log component */

log_result =

_log_create_component();

 

if(log_result != MQX_OK) {

printf(

"Error: log component could not be created\n");

}

/* endif */

#endif

#if

MQX_KERNEL_LOGGING == 1

 

/* create log number 0 */

log_result =

_klog_create(5000, LOG_OVERWRITE);

 

if(log_result != MQX_OK) {

printf(

"Error: log 0 could not be created\n");

}

/* endif *//* define kernel logging */_klog_control(0xFFFFFFFF, FALSE);

 

_klog_control(

KLOG_ENABLED |

KLOG_FUNCTIONS_ENABLED |

KLOG_INTERRUPTS_ENABLED |

// KLOG_SYSTEM_CLOCK_INT_ENABLED |

KLOG_CONTEXT_ENABLED |

KLOG_TASKING_FUNCTIONS |

KLOG_ERROR_FUNCTIONS |

KLOG_MESSAGE_FUNCTIONS |

KLOG_INTERRUPT_FUNCTIONS |

KLOG_MEMORY_FUNCTIONS |

KLOG_TIME_FUNCTIONS |

KLOG_EVENT_FUNCTIONS |

KLOG_NAME_FUNCTIONS |

KLOG_MUTEX_FUNCTIONS |

KLOG_SEMAPHORE_FUNCTIONS,

//DES was |

// KLOG_WATCHDOG_FUNCTIONS,

TRUE

);

#endif

 

Just #define them to 1 and place in user_config.h, recompile RTOS then application and run.

Check that stacks are not overflowing.

Sprinkle holy water about :smileywink:

Regards,

David

0 Kudos

1,599 Views
CarlFST60L
Senior Contributor II

Hi Guys,

After about 5 years of random watchdog resets (happens once a year per device on average) I have finally narrowed it down to MQX exception i.e. _int_exception_isr being called (now that I have installed the _int_install_unexpected_isr(); _int_install_exception_isr();) . When I put the unit under full load using some custom tools occasionally (once per 5 minutes) I get the _int_exception_isr called by MQX.

The parameter passed to _int_exception_isr is 0x20003890. How do I find out what exactly is causing the exception? I have read a load of threads and documents and cant work out how to track down exactly what is causing this error. The function notes that the parameter passed is the vector number, but how does 0x20003890 relate to the vector table, and/or what caused the exception?

Using MQX3.7 with TAD, I set teh break point at _int_install_exception_isr but from there I am not sure how to narrow it down to the exact cause.

1,599 Views
evgenyerlihman
Contributor IV

Hey Carl,

The value of parameter is an address, here is an example how you can extract vector number etc:

void _int_unexpected_isr

   (

      /* [IN] the parameter passed to the default ISR, the vector */

      pointer parameter

   )

{ /* Body */

   KERNEL_DATA_STRUCT_PTR            kernel_data;

   PSP_BASIC_INT_FRAME_STRUCT_PTR    basic_frame_ptr;

   PSP_INTERRUPT_FRAME_STRUCT_PTR    frame_ptr;

   TD_STRUCT_PTR                     td_ptr;

   volatile uint_32                           vector, offset;

   _GET_KERNEL_DATA(kernel_data);

   td_ptr      = kernel_data->ACTIVE_PTR;

   if (kernel_data->IN_ISR == 1) {

      /* Get the pointer to the data stored on the task stack */

      basic_frame_ptr = (pointer)td_ptr->STACK_PTR;

   } else {

      frame_ptr = (PSP_INTERRUPT_FRAME_STRUCT_PTR)&parameter;

      basic_frame_ptr = &frame_ptr->BASIC_FRAME;

   }/* Endif */

   vector = PSP_FAV_GET_VECTOR_NUMBER(basic_frame_ptr->FRAME.FORMAT_AND_VECTOR);

   offset = PSP_FAV_GET_VECTOR_OFFSET(basic_frame_ptr->FRAME.FORMAT_AND_VECTOR);

   printf( "\n*** UNHANDLED INTERRUPT ***\n");

   printf( "Vector #: %d  0x%x\n\r",vector,vector);

   printf( "Offset  : %d  0x%x\n\r",offset,offset);

   printf( "Task Id: 0x%0x Td_ptr 0x%x Stack Frame: 0x%x\n\r",

      td_ptr->TASK_ID, td_ptr, basic_frame_ptr);

   printf( "Interrupt_nesting level: %d   PC: 0x%08x   SR: 0x%04x\n\r",

      kernel_data->IN_ISR,

      basic_frame_ptr->FRAME.RETURN_ADDRESS,

      basic_frame_ptr->FRAME.STATUS_REGISTER );

   td_ptr->STATE = UNHANDLED_INT_BLOCKED;

   _task_set_error_td_internal(td_ptr, MQX_UNHANDLED_INTERRUPT);

   kernel_data->IN_ISR = 0;

   _task_block();

} /* Endbody */

Thanks,

Evgeny

0 Kudos

1,599 Views
OldNick
Contributor IV

Thanks David.

No, I haven't installed any unexpected interrupt isr-s.

 

But I have set the J-link/Jtrace to capture exceptions, and find it is a hard fault.

 

I then enabled the bus-fault bit in the NVIC but stil got a hard fault.

 

Only occurs when I try to do _mem_alloc at speed.  If I step through I get a valid pointer.

 

Perhaps the silicon is broken?

 

0 Kudos

1,599 Views
DavidS
NXP Employee
NXP Employee

Hi OldNick,

I've been working on an ADC test and was getting a unexpected interrupt that killed my system.

With the unexpected interrupt installed, I got an output to terminal (or you could set a breakpoint in the routine: file int_unx.c function _int_unexpected_isr() ) that told me what vector cause the issue.

In my case it was vector #2....NMI.

I looked at the customer board and found that they had the NMI pin connected to a device that randonly was asserting the NMI.  So it really was my BSP that was in error.

I reconfigured the pin for GPIO and re-ran my test and it is running...running...running.  Fingers crossed it continues that way.

Regards,

David

1,599 Views
OldNick
Contributor IV

Right - so I found a few other posts that indicated a possible reason.

Flash instruction cache problems on Kinetis OM33Z silicon.

 

J-link options in EWARM trap all sorts of useful conditions.  But could not get ETM to work at all.

 

(Had thought it might be to do with off-boundary accesses or something equally obsure.)

 

Started happening just after I turned on the SD-card access through partition manager in MFS.

 

But - turned off the flachecash and the problem went away.  Have now ordered production silicon for my dev board.

 

Sorry to waste your time guys.

0 Kudos

1,599 Views
admin
Specialist II

Hello OldNick:

 

I am using PEG + software and I have the unhandled interrupt 0x41 like you.

 

Have you found the solution for it?

 

Could you tell me how to fix the problem?

 

Thanks

 

Frank

0 Kudos

1,599 Views
OldNick
Contributor IV

Frank,

my problem turned out not to be MQX, but Kinetis.  There is an errata on early die revision OMZ33

Flash cache does not work properly.

 

I noticed last week that MQX380 BSP for k60 also disables the flash cache, as if it is maybe going to be an ongoing problem with large flash-only parts.

 

Perhaps this only happened when code size went over 1/2 the total for your chip?

0 Kudos

1,599 Views
c0170
Senior Contributor III

Hi fzhu129,

 

do you really want to use any interrupt?

Did you "install" and enable all interrupts? What board are you using? Have you find out what the number of the fault is?

 

Regars,

MartinK

0 Kudos

1,598 Views
admin
Specialist II

Hello MartinK:

 

I don't install the interrupt handler. The board I use is the customized board based on TWR K60. However we use LQFP instead of BGA styled package.

 

My Bsp is good because I have run another app before.

 

The expcetion is hardfault. vector 03.    interrupt 0x41.

 

fzhu19

0 Kudos

1,598 Views
c0170
Senior Contributor III

Hi fzhu129,

 

step your code, dont run it from the beginning and find out where hardfault is generated. Could you?

One possible cause could be with touching to the peripheral register which does not have clock set.

 

Regards,

MartinK

0 Kudos