The mysterious TIMER32_0_IRQHandler

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

The mysterious TIMER32_0_IRQHandler

523 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Mon Sep 12 19:53:57 MST 2011
Once upon a time ... on a distant island, while creating a new program, things started to go wrong.

First, and strangely, the program began to stop in an infinite loop:

void IntDefaultHandler(void)
{
    while(1)
    {
    }
}
The problem was solved by creating the procedure for handling the timer in use to pause the program (delay32Ms()).

void TIMER32_0_IRQHandler (void) {

};
Finally, turn off the interruption, as it was not in use.
NVIC_DisableIRQ(TIMER_32_0_IRQn);
But I decided to find the cause, why the program had operated erratically and discovered something strange:

The interruption is only executed before calling the function: [B]GPIOSetValue()[/B]

For example:
If we execute the following code, the timer interrupt will be executed 3 times, all before entering the function:

Quote:
GPIOSetValue(PORT0,  7, 0);
GPIOSetValue(PORT0, 7, 0);
GPIOSetValue(PORT0, 7, 0);

Other code does not cause activation of the interruption:
while(1) {
i++;
}
So for this story have a happy ending, someone can tell me:

[SIZE=4]What has[/SIZE][SIZE=4] in particular the "[/SIZE][SIZE=4]GPIOSetValue" procedure for activating the interruption?[/SIZE]

Thank you!
0 Kudos
8 Replies

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Sep 20 08:57:54 MST 2011
Single stepping an instruction can use "single step" logic in the Cortex CPU.

Single stepping a function is done by setting a breakpoint in the background and running until the breakpoint is hit.

Thus the behaviour of interrupts being taken/not taken can vary between the two.

Regards,
CodeRedSupport
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Tue Sep 20 07:41:15 MST 2011
Good suggestion, but my question is:

Why does not trigger interruption when it is running code like:

xy = 3
xy++
etc.

But it is triggered by calling a procedure (even when empty)?

You noticed what I said when you ran the program?

Thank you.
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Sep 20 00:25:25 MST 2011
Its unclear to me as to whether your original program where you saw your problem was actually setting up the timer or not?

But that aside, have you tried simply clearing the interrupt within the Timer32 interrupt handler?

void TIMER32_0_IRQHandler (void) {
    LPC_TMR32B0->IR = 1;            /* clear interrupt flag */
};
Otherwise every time you exit the handler, you will immediately take the interrupt again.

Regards,
CodeRedSupport
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Mon Sep 19 13:29:37 MST 2011
Up
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Wed Sep 14 09:33:01 MST 2011
Attached the sample project.

In this program, I noticed that always executes the interrupt, before jumping to a procedure.
    enable_timer32(0);

    xy = 1;
    xy = 4; //So far so good.

    abc(); //interrupt
    abc(); //interrupt

    GPIOSetValue(PORT0, LED, 0); //interrupt
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Tue Sep 13 13:11:26 MST 2011
The 1111 is awfully small.  How much memory are you using ... you're probably clobbering the stack if you have a lot of nested functions, etc., or aren't careful with the memory since there isn't much to go around anyway.

When you compile your project at the moment, how much flash and sram are you using?
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Luis Digital on Tue Sep 13 12:38:47 MST 2011
I am using a LPC1111 and the code is simple.

Now I am busy finishing the application, but possibly tomorrow have available a small sample program for you.

Thank you.
0 Kudos

466 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Tue Sep 13 12:06:25 MST 2011
The GPIO code is most likely harmless.  My suspicion would be something fishy in the linker script.  What parts are you using?  If it's the 1343 and you're using the rom-based USB, are you taking into account that you need to reserve a segment of SRAM that's used by the ROM-based code?  You'll need to give a bit more information before anyone can really help you.
0 Kudos