Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Servicing LPC2368 Interrupts

Status
Not open for further replies.

Kvel

Junior Member level 1
Junior Member level 1
Joined
Apr 20, 2011
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,403
Dear all,

Beginner here.

I'm programming an LPC2368 board (ETT CP-JR ARM7) and am setting up P2.0 - P2.7 as GPIOs with rising edge interrupts. As far as the user manual suggests, when an interrupt occurs it will generate a VICVectAddr17, which is shared by EINT3 and all GPIO interrupts.

Since I'll need to service each pin interrupt differently, I'll need to find which pin caused the interrupt to service it properly. Now, as I'm understanding it, a simple if(FIO2PIN0 & 0x01) would tell me if P2.7 is high, and thus probably the one that generated the interrupt.

My issue is that, having multiple if() checks for the various pins, I suspect there will be a possibility of a situation arising where P2.6 generates an interrupt, is serviced properly, then P2.7 generates an interrupt. When the loops is checking for high bits, P2.6 may still be high from the previous already serviced interrupt, and if I check for the interrupt pin using the aformention if(FIO2PIN0 & 0x02) method, the P2.6 ISR loop might be called again unnecessarily.

Is there a way to go around this and have a cleaner way of checking the interrupts? The interrupt register IOIntStatus only states which port the interrupt came from, so is not really of any help to determine which pin produced the interrupt.

An idea that I'm considering is making the interrupts double-edge triggered (if at all possible, but the manual doesn't seem to exclude it) and using a software flag as a state machine of sorts to eliminate duplicate ISR calls before a signal falls back down.

Any input, suggestions or comments would be greatly appreciated.
 

I'm now thinking of setting up all the GPIO monitoring in software without using external interrupt modes, thus being able to monitor and control state changes.

Again, any input, suggestions or comments would be greatly appreciated.
 

Download 23xx user manual https://www.keil.com/dd/docs/datashts/philips/lpc23xx_um.pdf

in page 183 you can read that there is a IOxIntStatR (x depends on the port) in which you can read in which pin there was a rising edge detected, IO0IntStatF in which you can read in which pin there was a failing edge detected, and finally there is IOxIntClr in which you have to clear the interrupt bit after it has been served.

Alex

p.s. also check my post https://www.edaboard.com/threads/196143/, you may find ARMwizard useful, the pin interrupt functionality has not been added yet but you can do many other functions.
 
Last edited:
  • Like
Reactions: Kvel

    Kvel

    Points: 2
    Helpful Answer Positive Rating
I cannot understand how I managed to miss that. Many thanks.

Also, that tool seems to be excellent! I'm programming everything manually to get a better understanding of the LPC, but that program looks golden.

Thanks again.
 

Actually I have been using AVR for a few years but I'm kind of new to ARM too.
I was annoyed by the 32bit registers (in a 8bit register it is much easier to find a specific bit and set it) so I have started this tool to set the registers without spending half an hour to set pin direction or functionality.
One thing led to the other and I have added more settings and more devices, the bonus for me was that to do it I read (and I still am) many manuals and datasheets because i had to understand every feature before implementing it so I have learned many things about the operation and settings of ARM.
I will probably add the pin interrupt too in the next version but for now only EINT settings are implemented.

If you need a good source for reading you can download The Insider's Guide To The NXP LPC2300/2400 Based Microcontrollers from Insiders Guides, it is a free guide that explains the operation of LPC for each peripheral.

Also about your question, if both edges can be used for pin interrupt, you can, it says it in page 170 of the user manual:
2.2 Interrupt generating digital ports
• PORT0 and PORT2 provide an interrupt for each port pin.
• Each interrupt can be programmed to generate an interrupt on a rising edge, a falling edge, or both.

Alex
 
  • Like
Reactions: Kvel

    Kvel

    Points: 2
    Helpful Answer Positive Rating
I did read the Insider's Guide for the LPC2300 but found the manuals gave me clearer answers to my questions and troubles at this point. My previous experience is with the 8051, so the ARM7 is a different beast altogether.
 

Alex, or anyone else,

I have another minor question which I couldn't find a clear-cut answer to. If I'm servicing an interrupt, but ISR is halted by another interrupt with a higher priority, will the first ISR resume and complete after the higher priority ISR finishes?

This is assuming that you are using different Vicvector addresses with different priorities.


Keith
 

Yes, this is what happens in any mcu that uses recursive interrupts or interrupts in general, the execution returns always to the same point it was before the interrupt.
So if the first interrupt was halted by a second interrupt then when the second interrupt ends the execution will return at the same point it was before interrupt two started which is inside interrupt one.

Alex
 
  • Like
Reactions: Kvel

    Kvel

    Points: 2
    Helpful Answer Positive Rating
Cheers Alex!

I have to say that I'm enjoying the LPC2368.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top