View previous topic :: View next topic |
Author |
Message |
pilar
Joined: 30 Jan 2008 Posts: 197
|
Priority problems |
Posted: Fri Jul 09, 2010 8:44 am |
|
|
Hello, I am implementing a module with a PIC18F452 at 20MHz, which communicates with a GPRS modem using the serial port. This module must also listen any event that is present in RB0 and RB1 as external interrupts activated flanks, my problem is follows:
This modem has unique features that make the pic must be continually asking the modem to see if the sensitivity is adequate to TX the message. If the modem has a low or very low sensitivity the answers to the asking pic varies from a few milliseconds to reach minutes, so the pic must be continually listening to the modem. For that I am using the interruption INT_RDA. This interruption has the highest priority, after there are the external interrupts INT0 and INT1. But the problem occurs when there is an event in RB0 or RB1 and the pic is attending the interruption INT_RDA. The pic does not meet these breaks, be busy and miss the event. But if I change the order of priority of interrupts I run the risk of losing some character response from the modem.
Someone like me could help me with this problem.
Code: |
#priority INT_RDA, INT_RB, INT_RB1
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19384
|
|
Posted: Fri Jul 09, 2010 9:28 am |
|
|
Code: |
#include <18F452.h>
#device HIGH_INTS=TRUE
#priority INT_RB, INT_RB1
#int_rda HIGH
void RDA_INT_HANDLER(void) {
//Your INT_RB code
}
|
This says make INT_RB, the higher priority interrupt of the 'standard' interrupts, and make INT_RDA, a _hardware_ high priority interrupt, that can interrupt other interrupt events.
#PRIORITY, sets the 'polling' order among the standard interrupts. The code above, sets up a genuine hardware 'HIGH priority' interrupt.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
pilar
Joined: 30 Jan 2008 Posts: 197
|
|
Posted: Fri Jul 09, 2010 10:15 am |
|
|
Quote: | #include <18F452.h>
#device HIGH_INTS=TRUE
#priority INT_RB, INT_RB1
#int_rda HIGH
void RDA_INT_HANDLER(void) {
//Your INT_RB code
}
|
Hi Ttelmah, I do not understand. You tell me that within the RDA_INT () code I must to place the INT_RB(), INT_RB1() codes? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19384
|
|
Posted: Fri Jul 09, 2010 2:39 pm |
|
|
No.
I just typed 'RB' in the comment, instead of RDA.... The RDA handler needs to just contain your INT_RDA code. You need separate handlers for INT_RB, and INT_RB1.
As I said, what is posted shows how to setup INT_RDA, to be a hardware high priority interrupt.
There is one 'caveat' with this. Hopefully doesn't apply if the interrupts you show are the only ones being used?. On the PIC18, if hardware high priority interrupts are setup, INT_TIMER0 (or INT_RTCC), will always be a high priority interrupt if used.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
pilar
Joined: 30 Jan 2008 Posts: 197
|
|
Posted: Fri Jul 09, 2010 3:13 pm |
|
|
Thanks... |
|
![](templates/subSilver/images/spacer.gif) |
|