MOD54415 Pin IRQ state at initialization

for everything else
Post Reply
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

MOD54415 Pin IRQ state at initialization

Post by jediengineer »

I'm using 5 external pins for interrupt triggering on the MOD54415 - IRQ1, IRQ2, IRQ3, IRQ6, and IRQ7. Does the SetPinIrq function check the status of the pin (high or low) when it initializes? There are fiberoptic cables driving these pins high or low. When the system initializes, it automatically assumes that they are in a high state (hardware driven high at the moment) so they're set up to trigger the interrupt on the falling edge. But what happens if the IRQ pin is low to start? Will the system automatically enter the ISR? or will it wait for the next transition from high to low? In either case how do I check the status of the pin? can I poll it like a GPIO pin? Thanks!
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: MOD54415 Pin IRQ state at initialization

Post by Ridgeglider »

The default pin functions should be GPIO and so level could be determined before configuring the IRQ. However there may be no need to do that. When you call SetPinIrq() you spec the IRQ polarity to be rising, falling or both edges. So if you spec'd falling edge, and the line was already low, no IRQ will happen until the line falls. If it was lo, it needs to go hi (rising, so no IRQ) then fall again to trigger the IRQ. Usually, when you init an IRQ, you're setting up a response to a future condition w/o need to respond to something that's already occurred. Therefore the state of the line usually does not matter. In these cases an edge triggered IRQ , not level triggered IRQ works well. Additionally, there is not usually concern for the duration of hi or low periods. All you care about is the edge which the hardware is armed to capture. In my experience, edge triggering is much preferred and less problematic than level triggered IRQs. Level Triggering should be avoided. See the source for SetPinIrq() in C:\nburn\MOD5441X\system\pin_irq.cpp.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: MOD54415 Pin IRQ state at initialization

Post by Ridgeglider »

Forgot to add: Once you arm the IRQ to act on a particular edge, there is no need to poll the line: you WILL miss the edge that caused the IRQ!
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 Pin IRQ state at initialization

Post by jediengineer »

Thanks, you've confirmed my suspicion!! I wasn't aware that the default state was GPIO. Si before I set the pin function as IRQ, I can poll the pin and figure out what state it's in? To clarify my earlier statement, I do want the IRQ to be edge triggered and not level triggered. The instant that the level changes I need the ISR to run. The level at the pin will last hundreds of milliseconds to up to several minutes, so I definitely need edge triggering. so - I should be able to do just this:

Code: Select all

if (J2[48])
{
// do stuff
}

SetPinIrq( 48, -1, &myIsr);
This should be fine, yes? or should I set the pin function as GPIO to start, just to be sure, then set it as an IRQ like so:

Code: Select all

J2[48].function(0);

if (J2[48])
{
// do stuff
}

SetPinIrq( 48, -1, &myIsr);
Would this be the better or more proper way to accomplish the task or is it somewhat redundant? I'm pretty sure that I read that the pin function can be changed whenever, correct?

This will give me a chance to set up my environment and preload conditions based on the power-up state of that pin. so for example - this particular pin is driven high if its counterpart circuit has faults. So on startup, if there's a fault, the pin will be low. Setting the IRQ to edge trigger on a high to low transition is correct for the circuit since runtime will always have that pin high, therefore at startup, I need to check that pin to make sure I know what state it's in before I set the pin IRQ.
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: MOD54415 Pin IRQ state at initialization

Post by Ridgeglider »

I don't think you need to check the levels or do anything before arming the IRQ. Just call SetPinIrq(); the logic works in either of the two cases:

Case 1) Say level is lo when you arm IRQ to act on a falling edge. Nothing happens when you execute SetPinIrq() because even though the level is low, the hardware never sees an edge.... Remeber we're edge triggered, not level triggered. Then the level eventually changes to hi: no falling edge once again, so no IRQ action. Then, sometime later, the level eventually falls. This triggers an IRQ as expected on the falling edge.

Case 2) Level is hi when you arm IRQ to act on a falling edge. Once again, the hardware does not see a falling edge, so no IRQ in response to calling SetPinIrq(). When the level does eventually fall, an IRQ triggers on the edge. After the IRQ, the level rises: no IRQ.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 Pin IRQ state at initialization

Post by jediengineer »

Thanks, but I don't think I conveyed my IRQ needs correctly. FYI, this is for a power supply. I need the IRQ to trigger the ISR on the falling edge. In my case, the pin will remain low for milliseconds to minutes. Then it is reset to trigger on the rising edge, where it will remain for that same amount of time. The ISR needs to immediately change several conditions upon the falling or rising edge. These conditions effect how the program operates when the pin is low, and how it will operate when it is high. That being said, if the system triggers a fault through the IRQ pin, it will react to protect the power supply from exploding. If there's a fault present at startup, and I don't know about it, when the system powers on, you'll have fireworks. This is why I need to know the state of the pin prior to setting the IRQ - I need to make sure the system is protected. So can I poll the pin, then set the IRQ? or will that cause a problem?
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: MOD54415 Pin IRQ state at initialization

Post by Ridgeglider »

You can poll the pin before setting to IRQ mode. Once in IRQ mode, you need to reconfigure to GPIO to poll it.
jediengineer
Posts: 192
Joined: Mon Dec 17, 2012 6:24 am

Re: MOD54415 Pin IRQ state at initialization

Post by jediengineer »

Thanks Ridgeglider! I won't need to poll the pin once it's in IRQ mode. Thanks for the info!
Post Reply