![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
Re: Problems with interrupts: gie is cleared when I call a f |
Posted: Thu Aug 04, 2005 2:41 am |
|
|
Ask compiler questions at the forum for the compiler and you will get a faster response. You are at the right place here.
Code: | .................... mensaje[1]=0;
29CC: CLRF 5F
29CE: CLRF 17 //I don't know what it's in position 0x17 ¿?
29D0: BTFSC FF2.7 //FF2.7 is the GIE bit
29D2: BSF 17.7
29D4: BCF FF2.7
....................
.................... conversion_placas();
29D6: CALL 0146
29DA: BTFSC 17.7
29DC: BSF FF2.7
....................
.................... direccion_can=cpr1;
29DE: MOVLW 60 |
Address 17 is just the random address of a RAM variable used by the compiler. What the compiler does here is to save the GIE bit setting before calling the function and restoring it afterwards. The compiler is doing so to prevent re-entrancy. Very likely you are calling the function conversion_placas() also from within one of your interrupts.
Two solutions:
1) Rewrite your code so that conversion_placas() is not called by the interrupt routines.
or
2) Create a copy of conversion_placas() with a different name and call that function from your interrupt. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Sep 05, 2005 1:01 am |
|
|
Hi ckielstra!
Many thanks for your answer, I'm very grateful to you.
I call conversion_placas() only from main, and the result is different if conversion_placas() is either:
Quote: |
this function doesn't clear GIE when called:
void conversion_placas(void)
{
array_placas_destino_byte[0]=array_placas_destino;
}
but this function clears GIE!!:
void conversion_placas(void)
{
array_placas_destino_byte[0]=array_placas_destino;
array_placas_destino_byte[1]=array_placas_destino>>8;
} |
The problem is that I've many counters activated by interrupts, so if the compiler clears GIE, the counters don't work right.
What is worse, is that I have many functions like conversion_placas(), so GIE is cleared many times and my code doesn't work fine. So it's very difficult to apply one of the soultions you've propossed.
At this moment, I solve the problem writing "GIE=1" at the top of those functions that clear the GIE. It seems to work, but I don't know if doing this can corrupt something (overwrite the stack or somewhat). |
|
![](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
|