External IRQ's

Discussion to talk about software related topics only.
Post Reply
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

External IRQ's

Post by chrispol »

the following works but it seems that the inteerupt does not clear i get about 50 or 60 printf statements before it stops, and if i hold the button triggering the interrupt it keeps firing and chrashes

any ideas?

Code: Select all

INTERRUPT(IRQ1, 0x2100 )
{
  sim.eport.epfr = 0x02;
  iprintf("Interrupt1 \n");
}

INTERRUPT(IRQ2, 0x2300 )
{
  sim.eport.epfr = 0x08;
  iprintf("Interrupt2 \n");
}

INTERRUPT(IRQ3, 0x2500 )
{
  sim.eport.epfr = 0x20;
  iprintf("Interrupt3 \n");
}

INTERRUPT(IRQ4, 0x2700 )
{
  sim.eport.epfr = 0x80;
  iprintf("Interrupt4 \n");
}

sim.eport.eppar=0x4444; // All ext int's rising edge
    sim.eport.epddr=0x00;
    sim.eport.epier=0xAA;  //irq1,3,5,7
    SetIntc(0, (long)&IRQ1, 1, 1, 1);
    SetIntc(0, (long)&IRQ2, 3, 3, 1);
    SetIntc(0, (long)&IRQ3, 5, 5, 1);
    SetIntc(0, (long)&IRQ4, 7, 7, 1);
i also have the following interrups set

Code: Select all

INTERRUPT(ServoIsr,0x2600)
{}

 SetIntc(0,(long)GPTAServoIsr,41,4,6);
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: External IRQ's

Post by Chris Ruff »

Don't do Big Things in an Interrupt.

Printing is a Big Thing.

set a variable and print it in the task code

Chris
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
chrispol
Posts: 30
Joined: Mon Mar 08, 2010 8:46 am

Re: External IRQ's

Post by chrispol »

Ok, also sometimes while triggering interrupt 1 i get a printf for interrupt 2
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: External IRQ's

Post by tod »

Rewrite this using the OSSemPost/OSemPend like shown in the example code and you'll most likely find all your problems go away. On a 5272 I once looked into the performance hit and as I recall it was in the 50us range (from the last line in the Interrupt to just after the first line in the pending routine.) Also when I write interrupt handlers for the 5272 my first line of code is always a call or statement to disable the current interrupt. Otherwise you run the risk of getting interrupted again before the pending routine finishes. I can easily envision this causing a crash when you run out of stack space. Your pending code may also end up using USER_ENTER_CRITICAL() and USER_EXIT_CRITICAL() to prevent other interrupts or OS task switching from happening.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: External IRQ's

Post by lgitlitz »

The problem is likely due to the level 7 interrupt. Try removing the IRQ7 part and see if the rest works. Level 7 interrupts are unmaskable and must be handled different then normal interrupts. You can not use the normal INTERRUPT macro here since is uses some OS variables. You must manually save and restore all the registers in the interrupt routine manually. This can be helpful if you need a very quick interrupt as you can save only a single register instead of all 16. Last time I bench marked the interrupt cycle time I saw about 830nS for a normal interrupt and about 290nS for a level 7 interrupt with a single register push/pop. Look at the interrupt application note for more details about writing a level 7 interrupt. http://www.netburner.com/downloads/mod5 ... rrupts.zip

It is really a bad idea to try and use printf or the UARTs from within an interrupt. If you called openserial on the stdio port then the UART is using the interrupt based driver and it will not work at all once the mask is 0x2300 or higher. If you are using the debug port unmodified from boot then it is using a polling driver. This should work in the interrupt but is still not a good idea to use, problems can still occur. It is much better to just post to a semaphore and have a task do your UART printing.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: External IRQ's

Post by pbreed »

The programming manual says printf is not to be used in an interrupt.
As others have said remove the printf, make a task and your problem will go away.
Post Reply