![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
ILLIAS28
Joined: 11 Jan 2011 Posts: 42
|
interrupts priority pic18f252 |
Posted: Wed Jan 22, 2020 8:45 am |
|
|
Hi,
Could you please help me ?
I have used in my program 3 interrupts, timer0, timer1 and RDA serial, but i didn't use any priority. Which one will have priority on others?
Thank you very much. _________________ i am newbe |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 22, 2020 9:37 am |
|
|
Here is how to answer this question. Create a test program with three
simple interrupt stub routines:
Code: |
#include <18F46K22.h>
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOPBADEN
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
#int_timer0
void t0_isr(void)
{
int8 temp;
temp = 1;
}
#int_timer1
void t1_isr(void)
{
int8 value;
value = 2;
}
#int_rda
void rda_isr(void)
{
int8 c;
c = getc();
}
//======================================
void main()
{
while(TRUE);
} |
Compile the program and look at the .LST file below. Find the start of
the CCS interrupt dispatcher code. For the 18F46K22, this starts at
address 00008. Notice the order in which it checks the ISR flags.
This is your default priority. Notice that it's the same order as you
used for the isr routines in the source code, above.
Quote: | 00008: MOVWF 04
0000A: MOVFF STATUS,05
0000E: MOVFF BSR,06
00012: MOVLB 0
00014: MOVFF FSR0L,0C
00018: MOVFF FSR0H,07
0001C: MOVFF FSR1L,08
00020: MOVFF FSR1H,09
00024: MOVFF FSR2L,0A
00028: MOVFF FSR2H,0B
0002C: MOVFF PRODL,12
00030: MOVFF PRODH,13
00034: MOVFF PCLATH,14
00038: MOVFF TABLAT,15
0003C: MOVFF TBLPTRL,16
00040: MOVFF TBLPTRH,17
00044: MOVFF 00,0E
00048: MOVFF 01,0F
0004C: MOVFF 02,10
00050: MOVFF 03,11
00054: BTFSS INTCON.TMR0IE
00056: GOTO 0060
0005A: BTFSC INTCON.TMR0IF
0005C: GOTO 00C6
00060: BTFSS PIE1.TMR1IE
00062: GOTO 006C
00066: BTFSC PIR1.TMR1IF
00068: GOTO 00D0
0006C: BTFSS PIE1.RCIE
0006E: GOTO 0078
00072: BTFSC PIR1.RC1IF
00074: GOTO 00F2 |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19379
|
|
Posted: Wed Jan 22, 2020 1:26 pm |
|
|
On the PIC18, by default all interrupts have the same actual 'priority'.
None can interrupt another.
What PCM_programmer is showing you is the order in which the flags
will be tested, which determines which will be serviced first, if two
trigger at the same time.
This by default is the order they are declared in the code.
So the first interrupt you declare will be the first serviced.
You can change the scan order using #PRIORITY.
If you want actual 'priority' to allow one interrupt to be called inside
another, you have to add the declaration
#device HIGH_INTS=TRUE
near the start of your code. This then allows a physical two priority
system. The interrupts you want to have high priority you then declare
with
#INT_xxx HIGH
However some caveats then exist. Normally on the PIC18, INT_EXT
will always be high priority. |
|
![](templates/subSilver/images/spacer.gif) |
ILLIAS28
Joined: 11 Jan 2011 Posts: 42
|
interrupts priority pic18f252 |
Posted: Thu Jan 23, 2020 8:18 am |
|
|
Thank you very much for your explanations Ttelmah and PCM,
everything is clear now. _________________ i am newbe |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|