grzeh666
- 30th August 2008, 04:23
Hi!
This is my first post on the forum. I'd like to welcome everyone and thank in advance for any help.
I have a question about multiple interrupts. I'm working on a program for 18f4525 to control buttons,led and relays via couple o MCP23S17's. MCP's communicate with 18f by STI serial protocol.I want to keep code as simple as possible and limit the use of interrupts to minimum.
My idea of the program goes like that:
When switch is pressed MCP generates interrupt to 18f. Interrupt handler will just set the variable like specyfic_interrupt = 1, and than go to main program, execute it and find the right code with if statement.
My main concern with this approach is what will happen if another interrupt will occure during execution of previously received interrupt. I mean - if the code reach the right code for interrupt and start executing it, if another interrupt would be received the program will jump to interrupt handler, thus stopping execution of previous interrupt in the middle of it.
Is this case technically possible with buttons (to switch them so fast?). If it is - is there a way to secure my program from that case ?. Is this approach good at all or should I just code complete interrupt handlers ?
Thank You very much in advance for all the suggestions.
This is my first post on the forum. I'd like to welcome everyone and thank in advance for any help.
I have a question about multiple interrupts. I'm working on a program for 18f4525 to control buttons,led and relays via couple o MCP23S17's. MCP's communicate with 18f by STI serial protocol.I want to keep code as simple as possible and limit the use of interrupts to minimum.
My idea of the program goes like that:
When switch is pressed MCP generates interrupt to 18f. Interrupt handler will just set the variable like specyfic_interrupt = 1, and than go to main program, execute it and find the right code with if statement.
My main concern with this approach is what will happen if another interrupt will occure during execution of previously received interrupt. I mean - if the code reach the right code for interrupt and start executing it, if another interrupt would be received the program will jump to interrupt handler, thus stopping execution of previous interrupt in the middle of it.
Is this case technically possible with buttons (to switch them so fast?). If it is - is there a way to secure my program from that case ?. Is this approach good at all or should I just code complete interrupt handlers ?
Thank You very much in advance for all the suggestions.