Int Unexpected ISR not outputting?

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

Int Unexpected ISR not outputting?

Jump to solution
1,955 Views
ironsean
Contributor V

Hello,

I'm using MQX 4.2 and CodeWarrior 10.6.4 with a Kinetis K64F Freedom board and an IAR systems J-link. My code for some reason seems to be throwing an interrupt during some string operations (like scanf() to parse a string), which causes my main task to throw an MQX_UNHANDLED_INTERRUPT (0x00000041) error.

I've tried using int_install_unexpected_isr() to install the int_unexpected_isr() and output information about this unhandled interrupt. However, I don't see any output either on the console in codewarrior during debugging, nor in the output from the ttyd over a virtual com port on my PCs terminal window.

I could try and install an exception handler like int_exception_isr() as described here (General Technical MQX FAQ)) but that's a fair bit more complicated, and I'm not sure exactly what that would entail.  This post (Unhandled Interrupt ) shows an example implementation but I'm not sure it's up to date.

So the question is really this: What is the best way to track down the source of an unhandled interrupt?

thanks,

Sean

Labels (1)
0 Kudos
1 Solution
1,415 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

Please make below change.

fgets(input_buffer, 64, config_file);
sscanf(input_buffer, "%d %d %d %d %d %d", &one, &two, &three, &four, &five, &six);//DES wassscanf(input_buffer, "%d %d %d %d %d %d", one, two, three, four, five, six);

Regards,

David

View solution in original post

11 Replies
1,415 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Sean:

First we suggest our customers add _int_install_unexpected_isr (),  then you will know what the vector cause this issue through the terminal. But you didn't see any output.

Secondly, you also can use break point and check the MCU registers directly. I received several tickets about the unhandled interrupt source detection, in the end customer found it is a bug in his application code, most of time , it is a memory issue.

I recommend you read the following document, I think it is helpful for you to trace this issue.

Debugging and diagnosing hard faults on ARM Cortex-M CPUs

Regards

Daniel

0 Kudos
1,415 Views
ironsean
Contributor V

It is almost certainly a memory issue with my application, I'm just struggling to have any clue how I would track it down.

I installed the exception handling code mentioned in the thread I linked, and now I have a bit of information:

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x0000000b

R3:     0x0000000a

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00007530

R3:     0x00007530

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00000005

R3:     0x00000001

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00000002

R3:     0x00000001

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00000078

R3:     0x00000000

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x000000f0

R3:     0x00000000

R12:    0x00000000

LR:     0x00006de5

PC:     0x00006e62

PSR:    0x61000000

Task 0x10003 is my main task (I'm not sure how it got bumped from 0x10001, but that's a mystery for another time), and that's the task that calls sscanf() when it throws the hard fault.

I'll read through the page you linked, but I'm also wondering where I can get the documentation on what's output above. I'm assuming they're registers relating to the interrupt?

Any idea what I should be watching to see what causes the fault? Just step through and into functions until something triggers it?

Sean

0 Kudos
1,415 Views
ironsean
Contributor V

The break; call on line 444 of io_scanl.c is where the hardfault gets thrown. I'm not sure what I'm doing wrong here.

0 Kudos
1,412 Views
ironsean
Contributor V

made a change and now get this:

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x0000000b

R3:     0x00000001

R12:    0x00000000

LR:     0x00006db5

PC:     0x00006e32

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00007530

R3:     0xfffffffd

R12:    0x00000000

LR:     0x00006db5

PC:     0x00006e32

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00000005

R3:     0x00000000

R12:    0x00000000

LR:     0x00006db5

PC:     0x00006e32

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x00000002

R3:     0x00000000

R12:    0x00000000

LR:     0x00006db5

PC:     0x00006e32

PSR:    0x61000000

Opps, bad thing happened.

The exception [HardFault] throw by TASK 0x10003

Dump the exception frame as :

R0:     0xffffffff

R1:     0x0000000a

R2:     0x000000f0

R3:     0x00000000

R12:    0x00000000

LR:     0x00006db5

PC:     0x00006e32

PSR:    0x61000000

My calls are this:

fgets(input_buffer, 64, config_file);

sscanf(input_buffer, "%d %d %d %d %d %d", one, two, three, four, five, six);

The file contains "11 30000 5 2 120 240"

input_buffer contains "11 30000 5 2 120 240  "

and the values become

one == 1

two == 4294967293

three == 0

four == 0

five == 536813584

six == 0

0 Kudos
1,412 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

So without sscanf() it works but with it it does not?

If yes, then try increasing your task stack size.

I have been bitten by this kind of issue before.

Regards,

David

0 Kudos
1,412 Views
ironsean
Contributor V

Unfortinately, I've stepped through the code and the main task (which is believes is causing the the hardfault based on the exception code) and that doesn't seem to be the case. Although I have many tasks this issue happens early in startup so only one other task is running at this point aside from Main.

Stepping through the code, none of the stack usages change except the interrupt stack changes from 2x% to 83% when the interrupt and exception handling occurs.

error_log_task 88%

_mqx_idle_task 36%

main 28%

interrupt 83%

If I increase the error_log_task stack size It changes to  58% usage, but the hard fault still occurs. In fact, preventing the error_log_task from starting so only Main and Idle are running and the same problem occurs. The stack size is 4800 in the main task because it takes on more responsibility later. The char arrays are only 64 characters long.

0 Kudos
1,412 Views
ironsean
Contributor V

Removing the sscanf() call no longer generates a hardfault, but it also prevents me from parsing the string and doing what I need to. I've had similar problems with other string related functions here.

0 Kudos
1,412 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

Can you attach the example code?

You have to click the "Use advanced editor" link in upper right hand corner and then Attach in new window at bottom right.

Regards,

David

0 Kudos
1,412 Views
ironsean
Contributor V

Here is the project. There's a lot more in there, but the config.c, and main_task.c, files are the parts that get touched here. Also the SDcard handling code, in etc_sd.h/.c. There are some warnings for io_part_mgs_install() implicitly declared I haven't been able to clear up, but it doesn't stop the SDcard from installing and working properly.

Sean

0 Kudos
1,416 Views
DavidS
NXP Employee
NXP Employee

Hi Sean,

Please make below change.

fgets(input_buffer, 64, config_file);
sscanf(input_buffer, "%d %d %d %d %d %d", &one, &two, &three, &four, &five, &six);//DES wassscanf(input_buffer, "%d %d %d %d %d %d", one, two, three, four, five, six);

Regards,

David

1,415 Views
ironsean
Contributor V

That was exactly the issue. Now I feel silly. Thinking about that now it makes perfect sense.

Thank you for looking that over and pointing out my silly mistake.

Sean

0 Kudos