|
|
View previous topic :: View next topic |
Author |
Message |
kuwa Guest
|
Using "FAST" Interrupt on PIC18 |
Posted: Sun Aug 13, 2006 7:19 am |
|
|
When FAST keyward are used in #int_xxx, compiler outputs highpriority
interrupt code without saving registers.
The interrupt code is as follows.
Code: | 0008: MOVLB 0
000A: GOTO 0138
.................... #int_timer2 FAST
.................... void isr_timer2(void) {
.................... #ASM
.................... MOVFF 0xFE0,07
0138: MOVFF FE0,07
.................... #ENDASM
.................... }
013C: BCF F9E.1
013E: RETFIE 1 |
At 0008, code is always MOVLB 0.
It may overwrite 0 to BSR whichi is using in main program.
It will make trouble.
Why the compiler output such code?
How should I do to stop outputting the code, "MOVLB 0"? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Aug 13, 2006 7:40 am |
|
|
Read the datasheet on the PIC. Certain registers are saved by the PIC hardware. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Aug 13, 2006 8:53 am |
|
|
The MOVLB instruction was added in v3.228 (or v3.227) to fix a bug where a C coded interrupt was assuming to be in bank zero by default. Placing the MOVLB instruction at the interrupt vector address is a quick-and-dirty fix. It works but in programs like yours where you don't access any C variables it adds an unwanted 1 instruction overhead.
Just curious, what do you have located at adres 0x0007? If this is a C variable that you dind't fix at this location with a #locate instruction, then the CCS generated code is actually just what you need.
More information on the bug fix: http://www.ccsinfo.com/forum/viewtopic.php?t=24950 |
|
|
kuwa Guest
|
Thanks! |
Posted: Mon Aug 14, 2006 8:37 pm |
|
|
>Mark
Oh! I had overlooked "Fast Regester Stack".
I should have noticed it,"RETFIE 1".
So, I understand no trouble will be.
Thank you. |
|
|
kuwa Guest
|
Thank you |
Posted: Mon Aug 14, 2006 8:54 pm |
|
|
>ckielstra
Thank you for the explanation about the history.
And,it"s a interest Idea.
So,I tried it.
But, if I write follows,
Code: | #device HIGH_INTS=TRUE
#build (interrupt=0x07) |
interrupts start at 0x07 and 0x17.
So I thought, and made as follows.
Code: | #device HIGH_INTS=TRUE
#build (interrupt=0x20)
#org 0x008,0x017
int_high_ent()
{
#asm
**** own code
BCF 0x***.*
RETFIE 1
#endasm
}
#org 0x018,0x01f
int_low_ent()
{
#asm
goto 0x30 // priority low entry
#endasm
} |
I am able to want to do.
But,,, I know It's needless thing.
Thank you very much. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Aug 15, 2006 6:56 am |
|
|
The hardware will still jump to 0x08 and 0x18 and thus the 2 instructions at 0x07 and 0x17 will not get executed and thus not adding to the overhead. |
|
|
kuwa Guest
|
0x0016 |
Posted: Tue Aug 15, 2006 6:43 pm |
|
|
But, "MOVLB 0" for low priority interrupt is not 0x0016, as follows.
Code: | #build(interrupt=0x07)
0006: MOVLB 0
0008: GOTO 00AE
000C: NOP
000E: NOP
0010: NOP
0012: NOP
0014: NOP
0016: MOVFF FE8,05
001A: MOVFF FD8,06
001E: MOVFF FE0,07
0022: MOVLB 0
0024: MOVFF FE9,0D
0028: MOVFF FEA,08
002C: MOVFF FE1,09
.
. |
So, It may have trouble, if it jump to 0x17(exactly 0x16).
Thank you. |
|
|
|
|
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
|